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

share|improve this question
1  
Are you sure the batch files are identical on both servers? No missing spaces or extra newlines? – Nifle May 14 '13 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 '13 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. ;) – Ƭᴇcʜιᴇ007 May 14 '13 at 19:39
up vote 1 down vote accepted

try this:

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

You must log in to answer this question.

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