Rename Files

Discuss RoboTask here
Post Reply
dondada
Posts: 22
Joined: Fri May 20, 2005 11:30 am

Rename Files

Post by dondada »

All I'm trying to do is rename several existing files (which could number in the hundreds) to my selected filenames. I generate the files to rename using "Search for Files" and writing it to a text file. But for some reason it isn't working. See my task below with just 2 files for brevity. Thanks for the help.
;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|385352816
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task18"
Hide=INTEGER|0
ID=INTEGER|837599829
Name=STRING|"Rename Files"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
[Actions\Action1]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER
[Actions\Action1\Params]
destvar=STRING|"{CURRENTFILENAME}"
file=STRING|"C:\list"
line0=STRING|"G:\025837611.tif"
line1=STRING|"G:\02583768.tif"
linecount=STRING|"2"
sourcetext=STRING|"1"
[Actions\Action2]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER
[Actions\Action2\Params]
destvar=STRING|"NEWFILENAME"
line0=STRING|"G:\113.tif"
line1=STRING|"G:\114.tif"
linecount=STRING|"2"
sourcetext=STRING|"1"
[Actions\Action3]
ActionID=STRING|"A_FILE_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename File"
Params=FOLDER
[Actions\Action3\Params]
count=STRING|"1"
file0=STRING|"{CURRENTFILENAME}"
mask=STRING|"{NEWFILENAME}"
subdirs=STRING|"0"
[Actions\Action4]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
[Actions\Action5]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
 
 
Oleg
Site Admin
Posts: 3105
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Rename Files

Post by Oleg »

It's incorrect method, because second loop will execute for each file from first loop. Each line of your list must contain old and new filenames. See task below.
In "search for files" action use "Insert text after" parameter.
Also you can generate newfilename directly. I can write an example, if needed.

;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|565106205
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task281"
Hide=INTEGER|0
ID=INTEGER|2145157206
Name=STRING|"Rename Files (improved)"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action1\Params]
destvar=STRING|"{CURRENTFILENAME}"
file=STRING|"C:\list"
line0=STRING|"G:\025837611.tif, G:\113.tif"
line1=STRING|"G:\02583768.tif, G:\114.tif"
linecount=STRING|"2"
sourcetext=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{CURRENTFILENAME(0)}"""
Params=FOLDER

[Actions\Action2\Params]
icon=STRING|"1"
msg0=STRING|"{CURRENTFILENAME(0)}"
msg1=STRING|"{CURRENTFILENAME(1)}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_FILE_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename File"
Params=FOLDER

[Actions\Action3\Params]
count=STRING|"1"
file0=STRING|"{CURRENTFILENAME(0)}"
mask=STRING|"{CURRENTFILENAME(1)}"
subdirs=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
dondada
Posts: 22
Joined: Fri May 20, 2005 11:30 am

Rename Files

Post by dondada »

Yes, please write a task that uses the "search for" action and then generates a filename to rename and save the found file(s). Thanks!
Oleg
Site Admin
Posts: 3105
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Rename Files

Post by Oleg »

Which algorithm do you want to use to form new filename? I can offer you to use a sequence number of file. See task below.

;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|565106205
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task282"
Hide=INTEGER|0
ID=INTEGER|1685558832
Name=STRING|"Rename files by number"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_FILE_DELETE"
Enabled=INTEGER|-1
Name=STRING|"Delete File"
Params=FOLDER

[Actions\Action1\Params]
Count=STRING|"1"
deletedirs=STRING|"0"
file0=STRING|"c:\filelist.txt"
subdir=STRING|"0"
ToRecycleBin=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_FILE_SEARCH"
Enabled=INTEGER|-1
Name=STRING|"Create File List (c:\filelist.txt)"
Params=FOLDER

[Actions\Action2\Params]
After=STRING|"0"
aftercount=STRING|"0"
AfterLine=STRING|"0"
Before=STRING|"0"
beforecount=STRING|"0"
BeforeLine=STRING|"0"
createmode=STRING|"1"
date1=STRING|"20050716"
date2=STRING|"20050716"
destfile=STRING|"c:\filelist.txt"
DuringDays=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"C:\temp\*.txt"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderMonths=STRING|"1"
subdirs=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NUMFILE"" with value ""1"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"NUMFILE"
varvalue=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action4\Params]
destvar=STRING|"{CURRENTFILENAME}"
file=STRING|"C:\filelist.txt"
line0=STRING|"G:\025837611.tif, G:\113.tif"
line1=STRING|"G:\02583768.tif, G:\114.tif"
linecount=STRING|"2"
sourcetext=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_FILE_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename File"
Params=FOLDER

[Actions\Action5\Params]
count=STRING|"1"
file0=STRING|"{CURRENTFILENAME}"
mask=STRING|"{numfile}.txt"
subdirs=STRING|"0"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""numfile"""
Params=FOLDER

[Actions\Action6\Params]
incement=STRING|"1"
vaiable=STRING|"numfile"

[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Post Reply