Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.