Jump to content

Recommended Posts

Posted (edited)

I know I'm doing something wrong as I'm very much a novice at manipulating syntax but would someone be able to tell me why the following batch file won't work:

 

set LISTFILE=C:\Cleaning_Scripts\test2.csv

 

for /f %%A in (%LISTFILE%) do (

 

robocopy "E:\TEMP" "E:\%%A" /E /MIR

 

)

 

I'm wanting to replace folder contents with the blank 'state' of an empty one (TEMP). A list of folder names is in the LISTFILE.

 

The robocopy part works fine when run without variables but it's as if Windows is looking for an actual %%A folder instead of substituting in the proper name. I've used variables with AD account details fine, just not with folder names. I feel I've not understand the /f switch when using 'for'.

 

Thanks in advance for any help.

 

UPDATE: The problem lies with my csv source. The file was created by a separate powershell script and it seemingly can't be read by this batch script. If I create a text file myself with a few folder names in it everything's fine. Now I know I need to output in ASCII!

Edited by ZeldaVet
Update

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



×
×
  • Create New...