dewey September 22, 2011 at 12:25:55 Specs: Windows XP
I have files named MIMA0512xxxxxxxxxxxx where xxxxxxxxxxxx are variable characters. I want to add BT512PDF1O. to the beginning of each file so that it will look like this: BT512PDF1O.MIMA0512xxxxxxxxxx. When I use this command: ren MIMA0512?????????? BT512PDF1O.MIMA0512?????????? it drops off the 10 variable characters. Any ideas?
Would dewey need to dir the filenames into a file first? Something like this:
REM creating a file containing all of the files that match MIMA0512* dir /b MIMA0512* > file_list.tmp for /f "tokens=*" %a in (file_list.tmp) do ren %a BT512PDF1O.%a REM deleting temp file del /q /f file_list.tmp
That is very clever. I see what you are doing but it didn't work. I forgot one part. The original files actually look like this. MIMA0512??????????.txt or .zip. I changed your solution to 14 ?s and then to 10? plus .???. Finally I tried 2 lines, one with .txt and the other with .zip. It still did not work. I think the . is messing up the solution. Any other ideas?
Or try this... I put the BT512PDF1O into a variable and changed the ren command to ren %a %b%.%a
@echo off REM creating a file containing all of the files that match MIMA0512* dir /b MIMA0512* > file_list.tmp REM loading BT512PDF1O into a variable set b=BT512PDF1O for /f "tokens=*" %a in (file_list.tmp) do ren %a %b%.%a REM deleting temp file del /q /f file_list.tmp
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this
site. Computing.Net and Purch hereby disclaim all responsibility
and liability for the content of Computing.Net and its accuracy.