Can I create an automatic file sorting and ordering script?

Discuss RoboTask here
Post Reply
Nuno
Posts: 1
Joined: Fri Sep 24, 2021 10:17 pm

Can I create an automatic file sorting and ordering script?

Post by Nuno »

Hi,
before i ask my question I wish to thank you for your awesome software. I discovered it yesterday and I will use it forever, most probably lol.
I have a need to create a file sorting script. Of course, a download manager could have done it but since I now have a full-fledged suite I hope I can do something like so.
If file is zip, rar, 7z, tar.* then put it in \archives\ folder.
If file is mp3, wav, wma, etc then put the file in the media folder, and so on and so forth.
I would also want to group teh folder by years and month, so for example media\2021\10\myfile.mp3
Can it be done? I don't think I need specific instructions as I can figure it out on my own, but I just want to ask whether it is possible.
Thanks,
N.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Can I create an automatic file sorting and ordering scri

Post by Oleg »

Yes of course this is possible
I wrote an example how to do this.
The algorithm is not very simple but I hope you can figure it out.

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|1040932817
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1408"
Hide=INTEGER|0
ID=INTEGER|-673456280
LogOnAsUser=INTEGER|1
Name=STRING|"Sort files by type and date"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action16=FOLDER
Action17=FOLDER
Action18=FOLDER
Action19=FOLDER
Action2=FOLDER
Action20=FOLDER
Action21=FOLDER
Action22=FOLDER
Action23=FOLDER
Action24=FOLDER
Action25=FOLDER
Action26=FOLDER
Action27=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""source"" with value ""D:\testfolder\source"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"source"
varvalue=STRING|"D:\testfolder\source"

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

[Actions\Action11]
ActionID=STRING|"A_DIALOG_SHOWTEXT"
Enabled=INTEGER|0
Name=STRING|"Show Text"
Params=FOLDER

[Actions\Action11\Params]
autoclose=STRING|"0"
fromfile=STRING|"1"
line00000000=STRING|"{txt}"
linecount=STRING|"1"
timeout=STRING|"10"

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

[Actions\Action12\Params]
createmode=STRING|"1"
date1=STRING|"20210925"
date2=STRING|"20210925"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{txt}"
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|"0"
timesize=STRING|"1"
timevar=STRING|"DT"
WithoutPath=STRING|"0"

[Actions\Action13]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""target"" with value ""{arcfld}\{DateTimeToFormat({dt},yyyy)}\{DateTimeToFormat({dt},mm)}"""
Params=FOLDER

[Actions\Action13\Params]
expand=STRING|"1"
varname=STRING|"target"
varvalue=STRING|"{arcfld}\{DateTimeToFormat({dt},yyyy)}\{DateTimeToFormat({dt},mm)}"

[Actions\Action14]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|0
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action14\Params]
message=STRING|"{target}"
type=STRING|"3"

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

[Actions\Action15\Params]
destdir=STRING|"{target}"
f_count=STRING|"1"
file0=STRING|"{filename}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"*.*.new"
subdir=STRING|"0"
system=STRING|"1"

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

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

[Actions\Action17\Params]
comment=STRING|"media"

[Actions\Action18]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""txt"" with value """""
Params=FOLDER

[Actions\Action18\Params]
expand=STRING|"0"
varname=STRING|"txt"

[Actions\Action19]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action19\Params]
destvar=STRING|"MASK"
line0=STRING|"{mediamask}"
linecount=STRING|"1"
sourcetext=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""arcFld"" with value ""D:\testfolder\archive"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"arcFld"
varvalue=STRING|"D:\testfolder\archive"

[Actions\Action20]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""txt"" with value ""{txt}{source}\{mask}{EOL}"""
Params=FOLDER

[Actions\Action20\Params]
expand=STRING|"1"
varname=STRING|"txt"
varvalue=STRING|"{txt}{source}\{mask}{EOL}"

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

[Actions\Action22]
ActionID=STRING|"A_DIALOG_SHOWTEXT"
Enabled=INTEGER|0
Name=STRING|"Show Text"
Params=FOLDER

[Actions\Action22\Params]
autoclose=STRING|"0"
fromfile=STRING|"1"
line00000000=STRING|"{txt}"
linecount=STRING|"1"
timeout=STRING|"10"

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

[Actions\Action23\Params]
createmode=STRING|"1"
date1=STRING|"20210925"
date2=STRING|"20210925"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{txt}"
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|"0"
timesize=STRING|"1"
timevar=STRING|"DT"
WithoutPath=STRING|"0"

[Actions\Action24]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""target"" with value ""{mediafld}\{DateTimeToFormat({dt},yyyy)}\{DateTimeToFormat({dt},mm)}"""
Params=FOLDER

[Actions\Action24\Params]
expand=STRING|"1"
varname=STRING|"target"
varvalue=STRING|"{mediafld}\{DateTimeToFormat({dt},yyyy)}\{DateTimeToFormat({dt},mm)}"

[Actions\Action25]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|0
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action25\Params]
message=STRING|"{target}"
type=STRING|"3"

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

[Actions\Action26\Params]
destdir=STRING|"{target}"
f_count=STRING|"1"
file0=STRING|"{filename}"
hidden=STRING|"1"
ifexists=STRING|"1"
move=STRING|"1"
rename=STRING|"0"
renamemask=STRING|"*.*.new"
subdir=STRING|"0"
system=STRING|"1"

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

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""mediaFld"" with value ""D:\testfolder\media"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"mediaFld"
varvalue=STRING|"D:\testfolder\media"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""arcMask"" with value ""*.rar{EOL}*.zip{EOL}*.7z{EOL}*.tar"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varname=STRING|"arcMask"
varvalue=STRING|"*.rar{EOL}*.zip{EOL}*.7z{EOL}*.tar"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""mediaMask"" with value ""*.wav{EOL}*.jpg{EOL}*.wma{EOL}*.mp3"""
Params=FOLDER

[Actions\Action5\Params]
expand=STRING|"0"
varname=STRING|"mediaMask"
varvalue=STRING|"*.wav{EOL}*.jpg{EOL}*.wma{EOL}*.mp3"

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

[Actions\Action6\Params]
comment=STRING|"archives"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""txt"" with value """""
Params=FOLDER

[Actions\Action7\Params]
expand=STRING|"0"
varname=STRING|"txt"

[Actions\Action8]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action8\Params]
destvar=STRING|"MASK"
line0=STRING|"{arcmask}"
linecount=STRING|"1"
sourcetext=STRING|"1"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""txt"" with value ""{txt}{source}\{mask}{EOL}"""
Params=FOLDER

[Actions\Action9\Params]
expand=STRING|"1"
varname=STRING|"txt"
varvalue=STRING|"{txt}{source}\{mask}{EOL}"

Oleg Yershov
Post Reply