Delete pdf files by part of file name

Discuss RoboTask here
Post Reply
jan
Posts: 26
Joined: Wed Jan 22, 2025 4:36 pm

Delete pdf files by part of file name

Post by jan »

Hello everyone,

I would like to delete all PDF files in a folder that have __done in the file name and are older than 2 months.
Robotask should check every hour whether the folder contains such files.

Would anyone be willing to help me with this? Many thanks in advance.

Best regards, Ján
Oleg
Site Admin
Posts: 3169
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Delete pdf files by part of file name

Post by Oleg »

Look at my example below. Also pay attention to Date filter of the loop.
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.
The you can see it in task editor

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|45174721
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1540"
Hide=INTEGER|0
ID=INTEGER|1826496193
LogOnAsUser=INTEGER|1
Name=STRING|"Delete PDF with part of name"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
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 ""PDFFolder"" with value ""D:\Temp\pdf"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"PDFFolder"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"PDFFolder"
varvalue=STRING|"D:\Temp\pdf"

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

[Actions\Action2\Params]
_rt_variables_produced=STRING|"FDF_File"
createmode=STRING|"4"
createormodified=STRING|"1"
date1=STRING|"20250123"
date2=STRING|"20250123"
destvar=STRING|"FDF_File"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{PDFFolder}\*_done*.pdf"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"2"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action3\Params]
message=STRING|"{FDF_File}"
type=STRING|"3"

[Actions\Action4]
ActionID=STRING|"A_FILE_DELETE"
Enabled=INTEGER|-1
Name=STRING|"Delete File"
Params=FOLDER

[Actions\Action4\Params]
Count=STRING|"1"
deletedirs=STRING|"0"
deletereadonly=STRING|"0"
file0=STRING|"{FDF_File}"
hidden=STRING|"1"
subdir=STRING|"0"
system=STRING|"1"
ToRecycleBin=STRING|"1"

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

Oleg Yershov
jan
Posts: 26
Joined: Wed Jan 22, 2025 4:36 pm

Re: Delete pdf files by part of file name

Post by jan »

Hi Oleg,

Thanks for your answer and your effort. Since I am an absolute beginner, I have to ask how I can export the code to a *.tsk file. Can you please help me again?

best regards from Munich, Ján
Oleg
Site Admin
Posts: 3169
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Delete pdf files by part of file name

Post by Oleg »

I have to ask how I can export the code to a *.tsk file.
Select the necessary task and use menu Task->Export
Oleg Yershov
jan
Posts: 26
Joined: Wed Jan 22, 2025 4:36 pm

Re: Delete pdf files by part of file name

Post by jan »

Hello Oleg,

I have managed to import the task into Robotask.
Thanks again for your great help!

Ján
Post Reply