2

I'm looking to run a second batch command from .bat but after the first command has been done.

REN "myfile.txt" "my_file.txt"
start "title" "path"

Here, I want the rename command to be executed before the process I wanted to start that has been terminated or executed. why it doesn't work in sequence order?

Update:

Both commands work correctly in order if I put a 'pause' or /sleep between the commands.

6
  • 2
    What leads you to believe the commands aren't being executed in order? Are you seeing output that implies otherwise? It just possible that the rename command isn't working as you'd expect? Commented Apr 17, 2010 at 22:10
  • Rename command is working but after the start process command. Commented Apr 17, 2010 at 22:12
  • It should work as you describe; can you post a test case that shows that it doesn't? Try changing your start to "start cmd /c dir path\my*.*" Commented Apr 17, 2010 at 22:17
  • If you have anti-virus software, disable it and see if it then works as expected. AV can interfere with file operations. Commented Apr 18, 2010 at 1:54
  • @sean: You should either get an error or a wait until completion in any case. Commented Apr 18, 2010 at 8:35

1 Answer 1

1

Try putting the REN command in a separate batch file--I think CALL may force the batch to wait until it returns:

-- file1.bat

CALL file2.bat "myfile.txt" "my_file.txt"
start "title" "path"

-- file2.bat

REN %1 %2
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.