1

I am trying to write a batch script that will rename folders that are defined in a list.txt file.

FOR /F %%a IN (C:\SCRIPTS\list.txt) DO RENAME "%%a" "%%a_delete" && EVENTCREATE /T INFORMATION /L APPLICATION /SO BLERG /ID 200 /D "MOVE %%a to %%a_old

In my list.txt file, I have the full paths defined.

C:\FolderA\Folder1
C:\FolderA\Folder9
C:\FolderB\Folder8
C:\RECYCLER\S-1-5-yn8o2-0p\6n2x-0p\n\Folder99

When I run the batch file, I get an error "THE SYNTAX OF THE COMMAND IS INCORRECT."

Funny thing is, this tested fine on an in-house server (both are Windows Server 2003 R2 Standard x64 SP2)

3
  • 1
    Are you sure the batch files are identical on both servers? No missing spaces or extra newlines?
    – Nifle
    May 14, 2013 at 19:23
  • I have no insight apart from my previous comment. But all my fellow sysadmins working with windows tell me that learning PowerShell is well worth it.
    – Nifle
    May 14, 2013 at 19:27
  • You're missing an ending quote on the Description argument (/D) for EventCreate, but I'm guessing that's a paste error. ;) May 14, 2013 at 19:39

1 Answer 1

1

try this:

FOR /F "usebackqdelims=" %%a IN ("C:\SCRIPTS\list.txt") DO RENAME "%%~a" "%%~nxa_delete"

You must log in to answer this question.

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