Delete all files from a folder that is located in multiple locations? One Command

Discuss RoboTask here
Post Reply
anthonyystwarty
Posts: 52
Joined: Fri Dec 30, 2022 2:43 am

Delete all files from a folder that is located in multiple locations? One Command

Post by anthonyystwarty »

Hi Olleg, Congratulations.

Is there any way to delete all files from a folder that is located in multiple locations?
With just one command? For example:

C:\Test\Pictures\Temp\image.jpg
C:\Test\Videos\Temp\heart.mpg
C:\Test\Windows\Temp\audio.mp3

How can I delete only the files from the temp folder, with just one command?
felipe
Posts: 17
Joined: Thu Nov 30, 2023 6:18 pm

Re: Delete all files from a folder that is located in multiple locations? One Command

Post by felipe »

You can add multiple folder and file, it will create a directory list
delet.jpg
delet.jpg (30.7 KiB) Viewed 1716 times
anthonyystwarty
Posts: 52
Joined: Fri Dec 30, 2022 2:43 am

Re: Delete all files from a folder that is located in multiple locations? One Command

Post by anthonyystwarty »

Thanks for the answer, yes, I use this, but I would like to not need to add all the folders to be deleted, I need something like a command that searches all the \Temp folders that are in C:\ and deletes all the files.
Congratulations
Oleg
Site Admin
Posts: 3088
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Delete all files from a folder that is located in multiple locations? One Command

Post by Oleg »

I need something like a command that searches all the \Temp folders that are in C:\ and deletes all the files.
In this case you must search all folders named Temp in the File Loop.
Use "By folders only" option.
And delete the necessary files inside the loop in every folder you find.
Oleg Yershov
anthonyystwarty
Posts: 52
Joined: Fri Dec 30, 2022 2:43 am

Re: Delete all files from a folder that is located in multiple locations? One Command

Post by anthonyystwarty »

Hello Oleg, How are you? Unfortunately I couldn't do it, because I didn't understand how it works due to my language, could you help me?
Does Fileloop delete files? Sorry for the inconvenience.
Attachments
Screenshot_1.png
Screenshot_1.png (24.79 KiB) Viewed 1364 times
Oleg
Site Admin
Posts: 3088
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Delete all files from a folder that is located in multiple locations? One Command

Post by Oleg »

Look at this example below.
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.
then you can see in 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|1075658632
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1455"
Hide=INTEGER|0
ID=INTEGER|-1167522676
LogOnAsUser=INTEGER|1
Name=STRING|"Remove files in TEMP subfolders"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
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 ""StartFolder"" with value ""C:\test"""
Params=FOLDER

[Actions\Action1\Params]
_rt_variables_produced=STRING|"StartFolder"
expand=STRING|"0"
linecount=STRING|"1"
varname=STRING|"StartFolder"
varvalue=STRING|"C:\test"

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

[Actions\Action2\Params]
_rt_variables_produced=STRING|"FolderToClear"
createmode=STRING|"1"
date1=STRING|"20241003"
date2=STRING|"20241003"
destvar=STRING|"FolderToClear"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{StartFolder}\temp"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"1"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"1"
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|"clear folder {FolderToClear}"
type=STRING|"3"

[Actions\Action4]
ActionID=STRING|"A_FILE_DELETE"
Enabled=INTEGER|-1
Name=STRING|"Delete File // delete file in TEMP subfolder"
Params=FOLDER

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

[Actions\Action5]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
The task searches for TEMP subfolders in some StartFolder folder and deletes files in the found folder.
Oleg Yershov
anthonyystwarty
Posts: 52
Joined: Fri Dec 30, 2022 2:43 am

Re: Delete all files from a folder that is located in multiple locations? One Command

Post by anthonyystwarty »

Thanks a lot for your assistance, you're always so helpful! The command worked now, that’s exactly what I needed!
Post Reply