Ren multiple files in DOS

Dell / GX280
June 3, 2009 at 04:23:56
Specs: Windows XP, 1GB
Any help would be appreciated.
I need to rename multiple files in a folder (to insert 4set characters at the beginning of the filename and move the numbers to the end of the file name) where the filename is typically an address (ie 27,Mystreet.doc) to read ABC_Mystreet,27.doc preferably via a DOS batch file? Any ideas?Thanks

See More: Ren multiple files in DOS

Report •

June 3, 2009 at 19:23:59
is ABC a constant? show real life examples of your file naming conventions and show more examples of your renamed file names.

Report •

June 3, 2009 at 23:46:44
Thanks for responding.Yes, ABC is a constant(actually its ASB_ ). The files are normally .doc or .pdf and the convention is nn streetname (ie 02 thomas street or 5 acorn road) - in a number of cases the filename also has COMPLETE as the final part of the filename ( 02 thomas street COMPLETE). The renamed file should read ASB_thomas street,02 or ASB_acorn road,2 (the COMPLETE is to be deleted in all cases)
Thanks again.

Report •

June 4, 2009 at 00:09:39
if you have Python on Windows
import os
for files in os.listdir(path):
    ext = files[-4:]
    if ext == ".doc" or ext == ".pdf":
        number,street = name.split(" ",1)
        newfilename = "ASB_"+street+","+number+ext

save the above as and on command line
C:\test>dir /B *.pdf *.doc
02 thomas street.pdf
5 acorn road.doc


C:\test>dir /B *.pdf *.doc
ASB_thomas street,02.pdf
ASB_acorn road,5.doc

Report •

Related Solutions

June 4, 2009 at 02:54:42
Sorry but i don't have Python (& our techies have locked down the pc's for software downloads!)
Is there an alternative solution using MSDOS Command prompt (WinXP)? (the python script does look the biz tho!)

Report •

Ask Question