ren al files in een direcoty with a extra extention

Started by pennym, August 20, 2014, 09:24:43 AM

Previous topic - Next topic

pennym

Dear all,
I am trying to rename in a directory all files.
I want to keep the name, but for all files i want to put
a number.
e001-orgininale filename
e002-orgininale filename
e003-orgininale filename
etc..


;my sample code is not working and i need some help,
DirChange("C:\temp")   
List1 = FileItemize("C:\temp\*.*")     
ptncount=ItemCount(List1,@TAB)   
For xx=1 TO ptncount           
ptn=ItemExtract(xx,List1,@TAB) ;

filerename("c:\temp\*.*", "c:\temp\e00%xx%*.*")
next
Message("Thats It", "all files were copied and renamed") 

pam

JTaylor

You are extracting the file names one-by-one in the For loop but then trying to do a rename on the entire directory.   Change your rename action to change one file at a time.

Jim

pennym

thx
is working now.

; Code posted to WinBatch Forum 2013.06.26 by kennytmcp
;my sample code is not working and i need some help,
DirChange("C:\temp")   
List1 = FileItemize("C:\temp\*.*")     
ptncount=ItemCount(List1,@TAB)   
For xx=1 TO ptncount           
ptn=ItemExtract(xx,List1,@TAB) ;
pause(xx,ptn)
filerename("c:\temp\%ptn%", "c:\temp\e00%xx%-%ptn%")
next

Message("Thats It", "all files were copied and renamed") 

Deana

Another option is to use FileMapName along with FileRename.
Deana F.
Technical Support
Wilson WindowWare Inc.