Batch script to rename file with existingname

November 4, 2010 at 02:54:43
Specs: Windows XP, 512
Hi, i have to rename all the files ina directory with their header information. Now my problem is there may two or more files with the same header say "account report" is the header, Now if use a batch script to rename these files only the first file gets renamed teh second file fails because the file name is already exists.. Can any body help me to solve this i want to rename the second file with teh same header as "Account report1" and then 3rd file to be "Account report2" so on.. Please help me to write this batch.

See More: Batch script to rename file with existingname

Report •

#1
November 4, 2010 at 18:35:26
More info please.

Is the header line always the first line in every file? Show an example of an actual header line. Show an example of the current filenames including extension..

Did you Google for an answer before asking the question?


Report •

#2
November 8, 2010 at 01:58:45
I have code that will rename the files with teh header. My concern is if two files has the same header say "Report" then the first file will get renamed as Repor.DOC and the second filr with the same header will fail with the error as " file name already exists" So what i need to do with this??

Report •

#3
November 8, 2010 at 23:37:22
You have to set up a counter for that filename and add the counter number to the filename whenever a file with that name is renamed, incrementing the counter after each rename.

Good luck.

Did you Google for an answer before asking the question?


Report •
Related Solutions


Ask Question