Page 1 of 2
Add characters to beginning of filename
Posted: Thu Jul 12, 2007 5:34 am
by Prem
Hi, I seek a way to add some characters to the beginning of the filename. I tried with the 'rename' function in Robotask, but that replaces the first characters of the filename with the given characters. I dont want to replace, but add to beginning of the filename.
Any ideas?
Thanks
Add characters to beginning of filename
Posted: Thu Jul 12, 2007 10:27 am
by Oleg
What is a problem? Suppose we have the file name in variable OldFileName
You can generate new file name as
123{OldFileName}
or
abc{OldFileName}
etc.
Add characters to beginning of filename
Posted: Sat Jul 14, 2007 8:17 am
by Prem
Thank you,
But I am still unsure how I should put the file name in variable OldFileName. Can you help me from the beginning please..
Sorry I'm not bright in this
Prem
Add characters to beginning of filename
Posted: Sat Jul 14, 2007 8:42 am
by Oleg
There are many methods to do this, e.g. "Set variable", "File loop", etc.
But I'm in doubt, Do you want to rename the file with fixed name or you don't know the name of file before action?
In first case you can rename file simply:
Rename MyFile.txt to 123MyFile.txt
In second case you must retrieve file name by some method and place it into variable.
Describe in more detail: what do you want to do?
Add characters to beginning of filename
Posted: Wed Jan 30, 2013 9:48 am
by trotta
I am trying to do this same thing. I need to rename files by adding a specific words onto the beginning. When I do, it replaces the first characters. I need the full name with new word on the beginning.
Old file name: knvieo.txt
New file name: Register_knvieo.txt
Add characters to beginning of filename
Posted: Wed Jan 30, 2013 10:08 am
by Oleg
If you try to remane file knvieo.txt to Register_*.* the action will replace symbols
You should calculate new name first.
See the example below:
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task26"
Hide=INTEGER|0
ID=INTEGER|1475693683
LogOnAsUser=INTEGER|1
Name=STRING|"generate new name"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""OLDFILENAME"" with value ""knvieo.txt"""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"OLDFILENAME"
varvalue=STRING|"knvieo.txt"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""NEWFILENAME"" with value """""
Params=FOLDER
[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"NEWFILENAME"
[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWFILENAME"" with value ""Register_{oldfilename}"""
Params=FOLDER
[Actions\Action3\Params]
expand=STRING|"1"
varname=STRING|"NEWFILENAME"
varvalue=STRING|"Register_{oldfilename}"
[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Old name: {oldfilename}"""
Params=FOLDER
[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"Old name: {oldfilename}"
msg1=STRING|"New name: {newfilename}"
msg3=STRING|"Now you can use ""Rename file"""
msg4=STRING|"rename {chr(123)}oldfilename{chr(125)} to {chr(123)}newfilename{chr(125)}"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"
Add characters to beginning of filename
Posted: Wed Jan 30, 2013 10:21 am
by trotta
For some reason it is still cutting off part of the file name. This is what it is doing:
Old file name: knvieo.txt
New file name: Register_.txt
Also it needs to add to all of the files in the folder.
Add characters to beginning of filename
Posted: Wed Jan 30, 2013 10:30 am
by Oleg
You should use use parameters in "Rename file" action
{oldfilename} in "Files" field
{newfilename} in "Rename to" field (not a mask, only {newfilename})
Add characters to beginning of filename
Posted: Wed Jan 30, 2013 10:34 am
by trotta
Hmm still does not work the way I need it to:
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|1833531447
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task44"
Hide=INTEGER|0
ID=INTEGER|1475693683
LogOnAsUser=INTEGER|1
Name=STRING|"generate new name (imported)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""OLDFILENAME"" with value ""*.txt"""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"OLDFILENAME"
varvalue=STRING|"*.txt"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""NEWFILENAME"" with value """""
Params=FOLDER
[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"NEWFILENAME"
[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWFILENAME"" with value ""Counts_{oldfilename}"""
Params=FOLDER
[Actions\Action3\Params]
expand=STRING|"1"
varname=STRING|"NEWFILENAME"
varvalue=STRING|"Counts_{oldfilename}"
[Actions\Action4]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER
[Actions\Action4\Params]
destdir=STRING|"C:\Users\rotttk\Desktop\Reports\Renamed Files"
f_count=STRING|"1"
file0=STRING|"C:\Users\rotttk\Desktop\Reports\*.txt"
hidden=STRING|"0"
ifexists=STRING|"0"
move=STRING|"0"
subdir=STRING|"0"
system=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|"{oldfilename}"
ifexists=STRING|"1"
mask=STRING|"{NEWFILENAME}"
subdirs=STRING|"0"
[Actions\Action6]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Old name: {oldfilename}"""
Params=FOLDER
[Actions\Action6\Params]
icon=STRING|"1"
msg0=STRING|"Old name: {oldfilename}"
msg1=STRING|"New name: {newfilename}"
msg3=STRING|"Now you can use ""Rename file"""
msg4=STRING|"rename {chr(123)}oldfilename{chr(125)} to {chr(123)}newfilename{chr(125)}"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"
Add characters to beginning of filename
Posted: Wed Jan 30, 2013 11:25 am
by Oleg
Try this, please (see below)
variables OldFileName and NewFileName should contain exact file names (not masks) in your case.
Therefore, you must use File Loop, because you don't know names beforehand.
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task41"
Hide=INTEGER|0
ID=INTEGER|1983060658
LogOnAsUser=INTEGER|1
Name=STRING|"generate new name"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""OLDFILENAME"" with value ""*.txt"""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"OLDFILENAME"
varvalue=STRING|"*.txt"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""NEWFILENAME"" with value """""
Params=FOLDER
[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"NEWFILENAME"
[Actions\Action3]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER
[Actions\Action3\Params]
destdir=STRING|"C:\Users\rotttk\Desktop\Reports\Renamed Files"
f_count=STRING|"1"
file0=STRING|"C:\Users\rotttk\Desktop\Reports\*.txt"
hidden=STRING|"0"
ifexists=STRING|"0"
move=STRING|"0"
subdir=STRING|"0"
system=STRING|"0"
[Actions\Action4]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER
[Actions\Action4\Params]
createmode=STRING|"1"
date1=STRING|"20130130"
date2=STRING|"20130130"
destvar=STRING|"OLDFILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"C:\Users\rotttk\Desktop\Reports\Renamed Files\*.txt"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"
[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWFILENAME"" with value ""Counts_{ExtractFileName({oldfilename})}"""
Params=FOLDER
[Actions\Action5\Params]
expand=STRING|"1"
varname=STRING|"NEWFILENAME"
varvalue=STRING|"Counts_{ExtractFileName({oldfilename})}"
[Actions\Action6]
ActionID=STRING|"A_FILE_RENAME"
Enabled=INTEGER|-1
Name=STRING|"Rename File"
Params=FOLDER
[Actions\Action6\Params]
count=STRING|"1"
file0=STRING|"{oldfilename}"
ifexists=STRING|"1"
mask=STRING|"{NEWFILENAME}"
subdirs=STRING|"0"
[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"