WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: pennym on August 20, 2014, 09:24:43 AM

Title: ren al files in een direcoty with a extra extention
Post by: pennym on August 20, 2014, 09:24:43 AM
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
Title: Re: ren al files in een direcoty with a extra extention
Post by: JTaylor on August 20, 2014, 09:36:39 AM
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
Title: Re: ren al files in een direcoty with a extra extention
Post by: pennym on August 20, 2014, 11:55:03 AM
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") 
Title: Re: ren al files in een direcoty with a extra extention
Post by: Deana on August 20, 2014, 09:04:09 PM
Another option is to use FileMapName along with FileRename.