Batch file to rename files in a folder

Closed
poorani - Oct 29, 2009 at 04:32 AM
aprpillai Posts 4 Registration date Wednesday November 4, 2009 Status Member Last seen November 5, 2009 - Nov 5, 2009 at 02:53 AM
Hello,
I had a folder with 550 image files in it. i need to change the name of the image files with respect to the data present in an excel.
e.g. i'm having one excel which contains Market code & the corresponding market names as shown below

Market Code Market Name
500 atlanta
600 boston.

The image files are stored in the name of "Market Names" .Now i need to change the file names w.r.to Market code.


can anyone suggest me a solution for the same
Related:

1 response

aprpillai Posts 4 Registration date Wednesday November 4, 2009 Status Member Last seen November 5, 2009
Nov 5, 2009 at 02:53 AM
Hi,

Write a Macro to Read the Cell Ranges that contain Market Code & Market Name Values in a loop and take Market Code in one string Variable say: strMarketCode and Market Name in strMarketName and run the DOS Command REN in Shell command like the following to rename each file:

Call Shell("REN C:\MyFolder\" & strMarketName & " " & strMarketCode)

The shell command must be called for each file. It is better if you create a delay loop immediately after executing the above shell command to give some time to DOS to execute the command like the following:

T= timer
Do While timer < T+0.5
' delay
Loop

this will give a delay of half a second before running the next shell command. You may increase the time to one second or more.


Regards,
a.p.r. pillai
0