|ML> I have a lot (4000+) files with the naming pattern "randomname.etn"
|ML> I would like to rename them to the patern "name****.etn" where **** is a 4
|ML> digit number, in sequence.
---[---snipped---]---|
| call RxFuncAdd 'SysFileTree','rexxutil','SysFileTree'
| call RxFuncAdd 'SysMoveObject','rexxutil','SysMoveObject'
| rc = SysFileTree("*.etn","files","BO")
| do i = 1 to files.0
| targetname = 'name'||translate(format(i,4),'0',' ')||'.etn'
| error = SysMoveObject(files.i, targetname)
| if error \= 0 then
| say 'Error' error 'renaming "'files.i'" to "'targetname'"'
| end
I did a little diddling; I noticed that you set the rexx var RC in statement
3, but don't use it, so here is my version:
call RxFuncAdd 'SysFileTree', "rexxutil",'SysFileTree'
call RxFuncAdd 'SysMoveObject',"rexxutil",'SysMoveObject'
call SysFileTree "*.etn",'files',"BO"
do j=1 to files.0
ttt='name'right(j,4,0)".etn"
r=SysMoveObject(files.j,ttt)
if r\==0 then say 'Error' r 'renaming "'files.j'" to "'ttt'"'
end
__________________________________________________________________ Gerard S.