Answered by:
Batch File Rename Using CSV

Question
-
Hey Guys,
I have several folder that each contain 500-2000 files. In each folder I have a csv file that contains two columns with the headers current and new.
Columns A contains the current name and Column B contains the new name.
My csv file contains the filenames with the extension. Scripts have not been enabled by our IT so I am unable to run ps1 scripts.
Thanks for the help in advance.
Tuesday, December 24, 2013 4:58 PM
Answers
-
From this point, how would I set it so that only column1 is used to match file names and then rename to the matching cell in column 2?
- Marked as answer by Bill_Stewart Monday, February 10, 2014 10:38 PM
Tuesday, December 24, 2013 7:17 PM
All replies
-
So what's your question?
Bill
Tuesday, December 24, 2013 5:04 PM -
Does anyone know if a way to do this using a batch file or vbs?Tuesday, December 24, 2013 5:11 PM
-
Does anyone know if a way to do this using a batch file or vbs?
Have you looked through here yet?
http://gallery.technet.microsoft.com/scriptcenter
Don't retire TechNet! - (Don't give up yet - 12,420+ strong and growing)
Tuesday, December 24, 2013 5:38 PM -
This is a case where it will likely be easier to use vbscript and the FSO. Batch would work but I think that error management and logging would be easier to manage in VBScript.
¯\_(ツ)_/¯
Tuesday, December 24, 2013 5:53 PM -
Here are a bunch of different solutions: https://www.google.com/#newwindow=1&q=vbscript+use+csv+to+rename+files
¯\_(ツ)_/¯
Tuesday, December 24, 2013 5:55 PM -
Thanks jrv,
It looks like I was want to go the vbs using FSO route unless I can somehow get IT to enable scripts for me.
I have never really done any VB but will give it my best shot.
I know that I will need to start withthe following:
Dim
FSO
Set
FSO = CreateObject(
"Scripting.FileSystemObject"
)
'Initialize a few items
strSource = "C:\Test.csv"
'Open the source file to read it
Set inputFile = fso.OpenTextFile(strSource,ForReading)From this point, how would I set it so that only column1 is used to match file names and then rename to the matching cell in column 2?
Tuesday, December 24, 2013 6:46 PM -
From this point, how would I set it so that only column1 is used to match file names and then rename to the matching cell in column 2?
- Marked as answer by Bill_Stewart Monday, February 10, 2014 10:38 PM
Tuesday, December 24, 2013 7:17 PM -
Read the file in a loop.
Split each line with Split(). The first two elements of the array are column one and two.
a=Split(line,",")
fso.MoveFile a(0), a(1)That's it.
¯\_(ツ)_/¯
Tuesday, December 24, 2013 9:35 PM