Jump to content

Recommended Posts

Posted

How can I get this to work without errors?

FOR %%i IN (
file1.ext
file2.ext
file3.ext
) DO IF EXIST %%i (if not exist Folder md Folder & move /y %%i Folder)

This stops moving files after the first one because folder has been created. I would like it to continue.

If I leave out "if not exist Folder" if makes the directory and moves the files but the it shows an error after the first one that directory already exists.


Posted

You can fix it by adding some parentheses in order to help the command interpreter understand exactly which bits belong where.

@ECHO OFF
FOR %%i IN (file1.ext file2.ext file3.ext) DO (
IF EXIST %%i ((IF NOT EXIST Folder MD Folder) & MOVE /Y %%i Folder))

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...