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))

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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