Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a .bat file that moves a file; however, it is also opening the file in a new window, which I don't want it to do. Is there a way to avoid opening a new window or at least an option to close the window after moving the file?

In the example below, the batch file opens another window on each move command and does not continue after I close the window manually.

for /f %%f in ('dir /b c:\source\*.txt') do (
move c:\source\%%f C:\destination\myfile.TXT
IF EXIST myfile.TXT start /wait dtexec /F ImportFile.dtsx
IF EXIST myfile.TXT start /wait ren myfile.TXT myfile%date:~4,2%%date:~7,2%%date:~10,4%%time:~1,1%%time:~3,2%%time:~6,2%.TXT 
move C:\destination\myfile_* C:\destination\OldFiles\
)
share|improve this question

Dont use start /wait ren ...:

for /f %%f in ('dir /b c:\source\*.txt') do (
    move c:\source\%%f C:\destination\myfile.TXT
    IF EXIST myfile.TXT (
        start /wait dtexec /F ImportFile.dtsx
        ren myfile.TXT myfile%date:~4,2%%date:~7,2%%date:~10,4%%time:~1,1%%time:~3,2%%time:~6,2%.TXT
    )
    move C:\destination\myfile_* C:\destination\OldFiles\
)
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .