Move + Rename always deletes the first letter

Discuss RoboTask here
Post Reply
Peter
Posts: 2
Joined: Thu Oct 25, 2018 9:21 am

Move + Rename always deletes the first letter

Post by Peter »

Hi,

I have a task that always deletes the first letter of the filename after renaming it. Do you have any idea?

Files: D:\cloud\Upload\Temp\Incoming\INFO_*.*
Destination: D:\cloud\School\blabla\management\2018-19
Rename to: {DateTimeToFormat({Date},yyyymmdd)}_*.*

Do you have any idea?

Thanks in advance
Chris
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Move + Rename always deletes the first letter

Post by Oleg »

What the initial file name?
Give me some examples for investigation, please
Oleg Yershov
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Move + Rename always deletes the first letter

Post by Oleg »

Auto-renaming by mask works with its own algorithms. This algorithm is very similar to system command REN (rename)
Maybe it doesn't correspond to your purposes.
In this case you have to calculate new file name before renaming
Look at this example

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task538"
Hide=INTEGER|0
ID=INTEGER|1319745359
LogOnAsUser=INTEGER|1
Name=STRING|"rename"
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

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""OLDFILENAME"" with value ""D:\cloud\Upload\Temp\Incoming\INFO_MyFilenameExample.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"OLDFILENAME"
varvalue=STRING|"D:\cloud\Upload\Temp\Incoming\INFO_MyFilenameExample.txt"

[Actions\Action2]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//calculate new file name"
Params=FOLDER

[Actions\Action2\Params]
comment=STRING|"calculate new file name"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWFILENAME"" with value ""{DateTimeToFormat({Date},yyyymmdd)}_{ExtractFileName({OldFileName})}"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"1"
varname=STRING|"NEWFILENAME"
varvalue=STRING|"{DateTimeToFormat({Date},yyyymmdd)}_{ExtractFileName({OldFileName})}"

[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{OldFileName}"""
Params=FOLDER

[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"{OldFileName}"
msg1=STRING|"rename to {newfilename}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
So, you have to move and rename files in the loop one-by-another.
You need calculate new filename for each file and put new file name explicitly

your task will look like this:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task539"
Hide=INTEGER|0
ID=INTEGER|-456484871
LogOnAsUser=INTEGER|1
Name=STRING|"rename in the loop"
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
Action6=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|"20181027"
date2=STRING|"20181027"
destvar=STRING|"OLDFILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"D:\cloud\Upload\Temp\Incoming\INFO_*.*"
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_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//calculate new file name"
Params=FOLDER

[Actions\Action2\Params]
comment=STRING|"calculate new file name"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NEWFILENAME"" with value ""{DateTimeToFormat({Date},yyyymmdd)}_{ExtractFileName({OldFileName})}"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"1"
varname=STRING|"NEWFILENAME"
varvalue=STRING|"{DateTimeToFormat({Date},yyyymmdd)}_{ExtractFileName({OldFileName})}"

[Actions\Action4]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//move and rename"
Params=FOLDER

[Actions\Action4\Params]
comment=STRING|"move and rename"

[Actions\Action5]
ActionID=STRING|"A_FILE_COPY"
Enabled=INTEGER|-1
Name=STRING|"Copy/Move File"
Params=FOLDER

[Actions\Action5\Params]
destdir=STRING|"D:\cloud\School\blabla\management\2018-19"
f_count=STRING|"1"
file0=STRING|"{OldFileName}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"1"
renamemask=STRING|"{NewFileName}"
subdir=STRING|"0"
system=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Save the text of the tasks to a file and use menu Task->Import to import the task into RoboTask.
Oleg Yershov
Peter
Posts: 2
Joined: Thu Oct 25, 2018 9:21 am

Re: Move + Rename always deletes the first letter

Post by Peter »

Hi!

Sorry that I respond so late.

Newfile: .\Incoming\Info_*.* (with Monitor it checks for new arrivals)
Destination: .\2018_19

RENAME to
{DateTimeToFormat({Date},yyyymmdd)}_*.*

Option: MOVE

Again: It does everything fine.... but leaves the first letter of every file name after the underscore (_)
paraffin
Posts: 21
Joined: Thu Jul 19, 2018 8:31 pm

Re: Move + Rename always deletes the first letter

Post by paraffin »

Hi

I am getting the same issue, if I rename the following file

ACCRUAL-HIGH-VALUE_20210614110613.csv

with a P2G_*.* I end up with a file called

PSG_UAL-HIGH-VALUE_20210614110613.csv

In my case this is removing the 4 Characters which is the same as the the amount of characters I want to add.

Any help appreciated at this seemed like the simple part of the routine
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Move + Rename always deletes the first letter

Post by Oleg »

Any help appreciated at this seemed like the simple part of the routine
You have to do this in the loop. This is similar to previous example (see task 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|0
CatID=INTEGER|1163085779
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1412"
Hide=INTEGER|0
ID=INTEGER|-456484871
LogOnAsUser=INTEGER|1
Name=STRING|"rename in the loop"
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
Action6=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|"20181027"
date2=STRING|"20181027"
destvar=STRING|"OLDFILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"D:\Temp\111\*.*"
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_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//calculate new file name"
Params=FOLDER

[Actions\Action2\Params]
comment=STRING|"calculate new file name"

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

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

[Actions\Action4]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//rename"
Params=FOLDER

[Actions\Action4\Params]
comment=STRING|"move and rename"

[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|"0"
mask=STRING|"{NewFileName}"
subdirs=STRING|"0"

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

Oleg Yershov
Post Reply