Renaming files

Discuss RoboTask here
Post Reply
deesloop
Posts: 70
Joined: Wed Feb 25, 2009 3:44 am

Renaming files

Post by deesloop »

I have a watched folder and PDFs get dropped into the subfolders of that folder.
I want to rename the files and copy to another folder using random nubmer in the filename was planning in using Move to do this
It works ok but all files are the same random number. and so all files are called 1234, 1234 (1), 1234 (2) etc

I want the filenames to be unique not all the same, not copies of each other.
I did try looping thru the folders but couldnt get it to work.

By not working I mean say there were 10 files
It would loop through all 10 files and renamed them 10 times
Perhaps cos Im using wildcards *.pdf?
deesloop
Posts: 70
Joined: Wed Feb 25, 2009 3:44 am

Re: Renaming files

Post by deesloop »

So I;ve come up with this.
But its stil creating duplicate names of files and appending a (1)
8 files in the folder, 123 files created in teh destination folder.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task3"
Hide=INTEGER|0
ID=INTEGER|1927866074
LocalVariables=STRING|"Filecount=0,Filename="
LogOnAsUser=INTEGER|1
Name=STRING|"Check stuck invoices."
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|1
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_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""FILENAME"" with value """""
Params=FOLDER

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

[Actions\Action2]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop for PDFs older than 5 minutes"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"9"
createormodified=STRING|"1"
date1=STRING|"20190619"
date2=STRING|"20190619"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
exclude=STRING|"Renamed*.pdf"
file0=STRING|"\\server1\InvoicesScanTest\*.pdf"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"1"
sortby=STRING|"1"
sortorder=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

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

[Actions\Action3\Params]
count=STRING|"1"
file0=STRING|"{FILENAME}"
ifexists=STRING|"0"
mask=STRING|"Renamed({RandomValue(1000000000)}.pdf"
subdirs=STRING|"0"

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

[Actions\Action4\Params]
destdir=STRING|"\\server1\InvoicesScan"
f_count=STRING|"1"
file0=STRING|"\\server1\InvoicesScanTest\Renamed*.pdf"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"Renamed{RandomValue(1000000)}"
subdir=STRING|"1"
system=STRING|"1"

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

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_FILE_MONITOR"
Params=FOLDER
UniqueID=INTEGER|-1274855013

[Events\Event1\Params]
chg=STRING|"0"
chga=STRING|"1"
chgsl=STRING|"1"
chgsm=STRING|"1"
chgtl=STRING|"1"
chgtm=STRING|"1"
del=STRING|"0"
folder1=STRING|"\\server1\InvoicesScanTest"
foldercount=STRING|"1"
incmask=STRING|"*.pdf"
interval=STRING|"30"
listmode=STRING|"1"
mon_files=STRING|"1"
mon_folders=STRING|"0"
new=STRING|"1"
pass=STRING|"0"
passmode=STRING|"1"
required=STRING|"0"
saveresults=STRING|"0"
subfolders1=STRING|"1"
deesloop
Posts: 70
Joined: Wed Feb 25, 2009 3:44 am

Re: Renaming files

Post by deesloop »

OK so the issue comes as it tries to rename all files.
I updated the loop to calculate a name and assigned to a variable and that works
Post Reply