Page 2 of 2

Re: Renaming Files Automation

Posted: Thu Apr 30, 2015 11:34 pm
by DSTP
Thanks for the helping me with this, however it's not changed any of the file names.

I've changed the base folder to the folder containing the images.
Imported task.
Run the program.
It finds the excel file.
Program runs through process.
Finished with no errors.
No file names have changed.

Please help!!

Re: Renaming Files Automation

Posted: Fri May 01, 2015 8:11 am
by Oleg
I tested this example on real files. It works. But I made some corrections.
see task below:

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
Action15=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_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action12\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"\"
source=STRING|"{oldname}"
substring=STRING|"/"
variable=STRING|"oldname"

[Actions\Action13]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action13\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"5"
height=STRING|"76"
icon=STRING|"3"
kind=STRING|"0"
message=STRING|"{oldname}{eol}{newname}"
position=STRING|"3"
title=STRING|"aaa"
width=STRING|"330"

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

[Actions\Action14\Params]
count=STRING|"1"
file0=STRING|"{OldName}"
ifexists=STRING|"0"
mask=STRING|"{ValidFileName({NewName})}.*"
subdirs=STRING|"0"

[Actions\Action15]
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}"


Pay attention that you have several errors in you EXCEL files
1. Old file name is invalid: l/071/product_80552_1_orig__18669.jpg
you use symbol "/" instead of "\". See step #12. it makes changes.
2. You use illegal symbols in new filenames.
For example the name lavender_star_foil_balloon_19"_15537 contains the quote char ". It is illegal symbol in file names
I use {ValidFileName({NewName})} variable. It removes invalid characters. See step #14

I created base folder with subfolders and files you specified in excel file and tested the task. It works.
Base folder is C:\basefolder
full folder structure before executing the task:

Code: Select all

Folders:
C:\basefolder\l
C:\basefolder\l\071
C:\basefolder\l\086
C:\basefolder\l\095
C:\basefolder\l\114
C:\basefolder\l\117
C:\basefolder\l\119
C:\basefolder\l\124
C:\basefolder\l\134
C:\basefolder\l\136
C:\basefolder\l\149
C:\basefolder\l\150
C:\basefolder\l\159
C:\basefolder\l\160

Files:
C:\basefolder\l\071\product_80552_1_orig__18669.jpg
C:\basefolder\l\086\lavender-star-foil-balloon-19andquot_-68186-1__00282.jpg
C:\basefolder\l\095\product_91410_1_orig__73411.jpg
C:\basefolder\l\114\product_68369_1_orig__40487.jpg
C:\basefolder\l\114\product_82170_1_orig__46304.jpg
C:\basefolder\l\117\product_65242_1_orig__50340.jpg
C:\basefolder\l\119\product_83381_1_orig__21846.jpg
C:\basefolder\l\124\product_67990_1_orig__40459.jpg
C:\basefolder\l\134\product_92711_1_orig__62499.jpg
C:\basefolder\l\136\product_69348_1_orig__90137.jpg
C:\basefolder\l\149\product_69598_1_orig__28787.jpg
C:\basefolder\l\149\product_91881_1_orig__96509.jpg
C:\basefolder\l\150\product_66808_1_orig__40297.jpg
C:\basefolder\l\159\product_96240_1_orig__75359.jpg
C:\basefolder\l\160\product_63352_1_orig__59536.jpg
Full folder structure after:

Code: Select all

Folders:
C:\basefolder\l
C:\basefolder\l\071
C:\basefolder\l\086
C:\basefolder\l\095
C:\basefolder\l\114
C:\basefolder\l\117
C:\basefolder\l\119
C:\basefolder\l\124
C:\basefolder\l\134
C:\basefolder\l\136
C:\basefolder\l\149
C:\basefolder\l\150
C:\basefolder\l\159
C:\basefolder\l\160

Files:
C:\basefolder\l\071\under_the_sea_fish_cutouts_35.6cm_18015
C:\basefolder\l\086\lavender_star_foil_balloon_19-_15537.jpg
C:\basefolder\l\095\dots_&_stripes_90th_birthday_poster_a3_14144.jpg
C:\basefolder\l\114\light_blue_latex_balloon_10-_15477.jpg
C:\basefolder\l\114\nautical_flag_picks-6.4cm__pack_50__14829
C:\basefolder\l\117\unijack_boater_16026.jpg
C:\basefolder\l\119\honk_honk_clown_horn_15052.jpg
C:\basefolder\l\124\blue_solid_colour_table_skirting_70cm_4.2m_17145
C:\basefolder\l\134\rubber_laurel_mask_17676.jpg
C:\basefolder\l\136\jungle_animals_paper_plates_16659.jpg
C:\basefolder\l\149\championship_football_favour_set_13920.jpg
C:\basefolder\l\149\tutu_much_fun_hats_15961.jpg
C:\basefolder\l\150\tiki_island_flower_straws_18149.jpg
C:\basefolder\l\159\child's_clown_dress_17831.jpg
C:\basefolder\l\160\balloon_ribbon_valves__white__15645.jpg