Page 1 of 2
Renaming Files Automation
Posted: Thu Apr 30, 2015 12:53 pm
by DSTP
I'm wanting to automate a process of renaming approx 9000 files.
The new & old file names are stored in a excel spreadsheet and I'd like robotask to find old file name and rename the relevant file from the spreadsheet.
Is this possible?
How would I go about doing this, I'm kinda computer savvy but struggling finding a step by step guide.
Any help would be appreciated.
Thanks in advance.
Chris
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 1:31 pm
by Oleg
I think yes. You can do this in the loop.
But I want to see the EXCEL file to say more details. Maybe I can create the small example
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 2:04 pm
by DSTP
If you could create a small example that would be appreciated..
The forum won't allow me to upload xls files, could you send me an email address
Cheers
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 2:18 pm
by Oleg
Yes, send the file to me (oleg (at) robotask.com )
BTW: now you can attach files in the forum. Use ZIP archive please.
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 2:29 pm
by DSTP
Zipped it!
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 2:41 pm
by Oleg
Describe in more detail, please. I understood so:
- old filename is the file in some subfolder;
- new filename should have the same extension;
- new file is in the same folder as original;
Is this correct?
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 2:47 pm
by DSTP
Thats correct.
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 3:02 pm
by Oleg
See this example (below)
Specify correct
base folder (step #1)
Specify correct filename of Excel file (step #2)
it should work
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1416408852
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task9"
Hide=INTEGER|0
ID=INTEGER|263140533
LogOnAsUser=INTEGER|1
Name=STRING|"Example for Excel"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER
[Actions\Action1]
ActionID=STRING|"A_FOLDER_CHANGE"
Enabled=INTEGER|-1
Name=STRING|"Change Folder (c:\basefolder)"
Params=FOLDER
[Actions\Action1\Params]
folder=STRING|"c:\basefolder"
[Actions\Action10]
ActionID=STRING|"A_LOOP_BREAK"
Enabled=INTEGER|-1
Name=STRING|"Break"
[Actions\Action11]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action12]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{oldName}"""
Params=FOLDER
[Actions\Action12\Params]
icon=STRING|"1"
msg0=STRING|"{oldName}"
msg1=STRING|"{newName}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action13]
ActionID=STRING|"A_FILE_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename File"
Params=FOLDER
[Actions\Action13\Params]
count=STRING|"1"
file0=STRING|"{OldName}"
ifexists=STRING|"0"
mask=STRING|"{NewName}.*"
subdirs=STRING|"0"
[Actions\Action14]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
[Actions\Action2]
ActionID=STRING|"A_EXCEL_OPEN"
Enabled=INTEGER|-1
Name=STRING|"Excel Open Document"
Params=FOLDER
[Actions\Action2\Params]
filename=STRING|"C:\Temp\downloads\Robotask.xlsx"
hide=STRING|"0"
mode=STRING|"0"
[Actions\Action3]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""ROW"" with value ""1"""
Params=FOLDER
[Actions\Action3\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"ROW"
varvalue=STRING|"1"
[Actions\Action4]
ActionID=STRING|"A_LOOP_WHILE"
Enabled=INTEGER|-1
Name=STRING|"While loop"
Params=FOLDER
[Actions\Action4\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"true"
[Actions\Action5]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""row"""
Params=FOLDER
[Actions\Action5\Params]
incement=STRING|"1"
vaiable=STRING|"row"
[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""OLDCELL"" with value ""R{row}C3"""
Params=FOLDER
[Actions\Action6\Params]
expand=STRING|"1"
varname=STRING|"OLDCELL"
varvalue=STRING|"R{row}C3"
[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWCELL"" with value ""R{row}C2"""
Params=FOLDER
[Actions\Action7\Params]
expand=STRING|"1"
varname=STRING|"NEWCELL"
varvalue=STRING|"R{row}C2"
[Actions\Action8]
ActionID=STRING|"A_EXCEL_GET"
Enabled=INTEGER|-1
Name=STRING|"Excel Get Cells"
Params=FOLDER
[Actions\Action8\Params]
cell00000000=STRING|"{OldCell}"
cell00000001=STRING|"{newCell}"
count=STRING|"2"
var00000000=STRING|"oldName"
var00000001=STRING|"NewName"
worksheet=STRING|"sheet1"
[Actions\Action9]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action9\Params]
case=STRING|"0"
operator=STRING|"7"
type=STRING|"0"
value1=STRING|"{OldName}"
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 4:15 pm
by DSTP
Cheers for writing the code.
Where would I place the edited code and how would I get it started.
Re: Renaming Files Automation
Posted: Thu Apr 30, 2015 4:46 pm
by Oleg
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.