Page 1 of 1
How to trim a filename after "-" and more
Posted: Wed Jan 06, 2010 12:05 am
by rice1973
Hi,How can i "trim" a filename before "-" and put behind "01"?Example;3621-271.20.10_3.jpgShould transform to;362101.jpgThe
are mutiple files, the amount of numbers for the "-" can be 1,2,3 or 4.
Different filenames that have to be changed in a specific directory.
How to trim a filename after "-" and more
Posted: Wed Jan 06, 2010 5:02 am
by Oleg
You have to use {ExtractFileNameNoExt()} variable in order to extract file neme without extension.
Next, extract first part (STR Extract action) add suffix and extension.
How to trim a filename after "-" and more
Posted: Wed Jan 06, 2010 5:58 am
by rice1973
Hi Oleg,What am i doing wrong?;*******************************;* RoboTask Task file *;* Do not edit in text editor! *;******************************* [Root]ActionAfterRun=INTEGER|0Actions=FOLDERAutomat=INTEGER|0CatID=INTEGER|87130928ContinueOnError=INTEGER|0ExternalName=STRING|"Task11"Hide=INTEGER|0ID=INTEGER|1120632189LocalVariables=STRING|"OldFileName,NewFileName,Apos"LogOnAsUser=INTEGER|1Name=STRING|"Trim after ""-"""Priority=INTEGER|3RunOnClose=INTEGER|0RunOnStartup=INTEGER|0ToLog=INTEGER|2WriteGeneralLog=INTEGER|0[Actions]Action1=FOLDERAction2=FOLDERAction3=FOLDERAction4=FOLDERAction5=FOLDERAction6=FOLDERAction7=FOLDERAction8=FOLDER[Actions\Action1]ActionID=STRING|"A_LOOP_FILE"Enabled=INTEGER|-1Name=STRING|"File Loop"Params=FOLDER[Actions\Action1\Params]createmode=STRING|"1"date1=STRING|"20100105"date2=STRING|"20100105"destvar=STRING|"OLDFILENAME"DuringDays=STRING|"1"DuringMonths=STRING|"1"file0=STRING|"T:\Packshot_origineel\*.*"filecount=STRING|"1"OlderDays=STRING|"1"OlderMonths=STRING|"1"savesize=STRING|"0"searchkind=STRING|"0"subdirs=STRING|"1"timesize=STRING|"0"WithoutPath=STRING|"0"[Actions\Action2]ActionID=STRING|"A_STR_POS"Enabled=INTEGER|-1Name=STRING|"STR Pos"Params=FOLDER[Actions\Action2\Params]case=STRING|"0"from=STRING|"2"search=STRING|"-"source=STRING|"{ExtractFileNameNoExt({OldFileName})}"variable=STRING|"APos"[Actions\Action3]ActionID=STRING|"A_STR_DELETE"Enabled=INTEGER|-1Name=STRING|"STR Delete"Params=FOLDER[Actions\Action3\Params]amount=STRING|"{APos}"from=STRING|"2"source=STRING|"{ExtractFileNameNoExt({OldFileName})}"variable=STRING|"NewFileName"[Actions\Action4]ActionID=STRING|"A_FLOW_IF"Enabled=INTEGER|-1Name=STRING|"If Then"Params=FOLDER[Actions\Action4\Params]case=STRING|"0"operator=STRING|"1"type=STRING|"0"value1=STRING|"{ExtractFileName({OldFileName})}"value2=STRING|"{NewFileName}"[Actions\Action5]ActionID=STRING|"A_ROBOTASK_LOG"Enabled=INTEGER|-1Name=STRING|"Log Message"Params=FOLDER[Actions\Action5\Params]message=STRING|"File {OldFileName} is renaming to {NewFileName} ..."type=STRING|"3"[Actions\Action6]ActionID=STRING|"A_FILE_RENAME"Enabled=INTEGER|-1Name=STRING|"Rename File"Params=FOLDER[Actions\Action6\Params]count=STRING|"1"file0=STRING|"{OldFileName}"mask=STRING|"{NewFileName}01.jpg"subdirs=STRING|"0"[Actions\Action7]ActionID=STRING|"A_FLOW_ENDIF"Enabled=INTEGER|-1Name=STRING|"End If"[Actions\Action8]ActionID=STRING|"A_LOOP_END"Enabled=INTEGER|-1Name=STRING|"End Loop"Results in 354.09.026_001.jpg from 3628-154.09.026_0.jpg
How to trim a filename after "-" and more
Posted: Wed Jan 06, 2010 6:52 am
by Oleg
You should remove characters from 1-st position. See step #3
How to trim a filename after "-" and more
Posted: Thu Jan 07, 2010 4:17 am
by rice1973
Hi Oleg,I can't get the "job" done.Can you help me out once more?Maurice
How to trim a filename after "-" and more
Posted: Thu Jan 07, 2010 11:50 pm
by Oleg
See the example below. It renames JPG files in folder as you described in 1-st post of this topic.
;*******************************
;* RoboTask Task file
;* Do not edit in text editor!
;*******************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|839555382
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task910"
Hide=INTEGER|0
ID=INTEGER|1869819216
LocalVariables=STRING|"OldFileName,NewFileName,Apos"
LogOnAsUser=INTEGER|1
Name=STRING|"Trim after ""-"""
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|2
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=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|"20100105"
date2=STRING|"20100105"
destvar=STRING|"OLDFILENAME"
DuringDays=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"c:\incoming\*.jpg"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"
[Actions\Action2]
ActionID=STRING|"A_STR_POS"
Enabled=INTEGER|-1
Name=STRING|"STR Pos"
Params=FOLDER
[Actions\Action2\Params]
case=STRING|"0"
from=STRING|"1"
search=STRING|"-"
source=STRING|"{ExtractFileNameNoExt({OldFileName})}"
variable=STRING|"APos"
[Actions\Action3]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action3\Params]
case=STRING|"0"
operator=STRING|"3"
type=STRING|"1"
value1=STRING|"{APos}"
value2=STRING|"0"
[Actions\Action4]
ActionID=STRING|"A_STR_DELETE"
Enabled=INTEGER|-1
Name=STRING|"STR Delete"
Params=FOLDER
[Actions\Action4\Params]
amount=STRING|"99"
from=STRING|"{APos}"
source=STRING|"{ExtractFileNameNoExt({OldFileName})}"
variable=STRING|"NewFileName"
[Actions\Action5]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action5\Params]
message=STRING|"File {OldFileName} is renaming to {NewFileName}01.jpg ..."
type=STRING|"3"
[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}"
mask=STRING|"{NewFileName}01.jpg"
subdirs=STRING|"0"
[Actions\Action7]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action8]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
How to trim a filename after "-" and more
Posted: Thu Jan 14, 2010 12:17 am
by rice1973
Thnx Oleg,Works fine......Again!