rename file on base of folder name 2.0

Discuss RoboTask here
Post Reply
jarra21
Posts: 2
Joined: Tue Jun 30, 2020 8:37 pm

rename file on base of folder name 2.0

Post by jarra21 »

So im trying to use this code as a base.
https://robotask.com/forum/viewtopic.ph ... foldername

Code: Select all

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task372"
Hide=INTEGER|0
ID=INTEGER|1259557504
LogOnAsUser=INTEGER|1
Name=STRING|"Rename files (only images2d)"
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_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FILENAME"" with value """""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"FILENAME"

[Actions\Action10]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""FILE"" with value ""{ExtractFileName({FileName})}"""
Params=FOLDER

[Actions\Action10\Params]
expand=STRING|"1"
varname=STRING|"FILE"
varvalue=STRING|"{ExtractFileName({FileName})}"

[Actions\Action11]
ActionID=STRING|"A_STR_REPLACE"
Enabled=INTEGER|-1
Name=STRING|"STR Replace"
Params=FOLDER

[Actions\Action11\Params]
case=STRING|"0"
mode=STRING|"0"
replacement=STRING|"{folder}-"
source=STRING|"{file}"
substring=STRING|"img_"
variable=STRING|"NewFile"

[Actions\Action12]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{FileName}"""
Params=FOLDER

[Actions\Action12\Params]
icon=STRING|"1"
msg0=STRING|"{FileName}"
msg1=STRING|"{File}"
msg2=STRING|"{Folder}"
msg3=STRING|"{NewFile}"
msgcount=STRING|"4"
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|"{FileName}"
ifexists=STRING|"1"
mask=STRING|"{NewFile}"
subdirs=STRING|"0"

[Actions\Action14]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

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

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FILE"" with value """""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"FILE"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FOLDER"" with value """""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"FOLDER"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""NEWFILE"" with value """""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"NEWFILE"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""PARENT"" with value """""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"PARENT"

[Actions\Action6]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action6\Params]
createmode=STRING|"1"
date1=STRING|"20140725"
date2=STRING|"20140725"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"d:\temp\images\*.jpg"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PARENT"" with value ""{ExtractFileName({ExtractFilePath({FileName})})}"""
Params=FOLDER

[Actions\Action7\Params]
expand=STRING|"1"
varname=STRING|"PARENT"
varvalue=STRING|"{ExtractFileName({ExtractFilePath({FileName})})}"

[Actions\Action8]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action8\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{parent}"
value2=STRING|"images2d"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""FOLDER"" with value ""{ExtractFileName({ExtractFilePath({ExtractFilePath..."""
Params=FOLDER

[Actions\Action9\Params]
expand=STRING|"1"
varname=STRING|"FOLDER"
varvalue=STRING|"{ExtractFileName({ExtractFilePath({ExtractFilePath({FileName})})})}"
My folder structure is E:\ArchivetoOptical\{folder}\*.mxf
Image

my goal is to have the foldername get pasted on to the .MXF file so for this example i want the .MXF to be named 0ba7415c2b924ef48224f2cc6e4360ce_4PM Focus Text and Drive VO 1005.mxf
or if possible would be 0ba7415c2b924ef48224f2cc6e4360ce_4PM Focus Text and Drive VO 10.05.mxf with the added period.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: rename file on base of folder name 2.0

Post by Oleg »

Do you want to add foldername to the filename? Do I understood correctly?
If so then look at my example below
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1163085779
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task220"
Hide=INTEGER|0
ID=INTEGER|1338142634
LogOnAsUser=INTEGER|1
Name=STRING|"Rename file (add foldername)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

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

[Actions\Action1\Params]
createmode=STRING|"1"
date1=STRING|"20200709"
date2=STRING|"20200709"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"E:\ArchivetoOptical\*.mxf"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""FOLDERNAME"" with value ""{ExtractFileName({ExtractFilePath({FileName})})}"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"1"
varname=STRING|"FOLDERNAME"
varvalue=STRING|"{ExtractFileName({ExtractFilePath({FileName})})}"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWFILENAME"" with value ""{foldername}.{ExtractFileName({filename})}"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"1"
varname=STRING|"NEWFILENAME"
varvalue=STRING|"{foldername}.{ExtractFileName({filename})}"

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

[Actions\Action4\Params]
count=STRING|"1"
file0=STRING|"{FileName}"
ifexists=STRING|"0"
mask=STRING|"{NewFilename}"
subdirs=STRING|"0"

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

Oleg Yershov
jarra21
Posts: 2
Joined: Tue Jun 30, 2020 8:37 pm

Re: rename file on base of folder name 2.0

Post by jarra21 »

Hey what you sent me worked 100%! Thank you so much! What kind of code would i need to add to make the renamed file move to my ArchivetoOptical folder? i tried the copy/move file function with E:\ArchivetoOptical\*\*.mxf but that does not seem to work. If its not to hard could you also help me with deleting the folder after the file has moved.

Thanks for your help!
Post Reply