Command to delete all files in a directory?
Moderators: Dorian (MJT support), JRL
-
- Newbie
- Posts: 8
- Joined: Thu Jun 07, 2007 10:45 pm
Command to delete all files in a directory?
Is there a command to delete all files in a directory? I don't want to delete the directory itself just everything in it. I am currently deleting the directory then recreating it but am looking for a better way.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Use the DOS command DEL with wildcards
-----------------------
Note - this is an edited sample. The original first line was in error as pointed out by JRL in a subsequent posting. The current posting is correct.
Code: Select all
LET>RP_WAIT=1
Run Program>C:\command.com /c DEL Drive:\Folder\*.*
...
Do More Stuff
-----------------------
Note - this is an edited sample. The original first line was in error as pointed out by JRL in a subsequent posting. The current posting is correct.
Last edited by Bob Hansen on Mon Jun 11, 2007 6:33 pm, edited 3 times in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
-
- Newbie
- Posts: 8
- Joined: Thu Jun 07, 2007 10:45 pm
What does wait_rp=1 do? I know most commands in the macro seem to change color when you type them in but this one remains black. Also the command doesn't work for me. Dos box comes up with specified command search bad. To many parameters. I think I am going to stick with just deleting and recreating since that works and doesn't seem to have any adverse effects. I would still like to know what wait_rp=1 does though =).Bob Hansen wrote:Use the DOS command DEL with wildcards
WAIT_RP=1
Run Program>C:\command.com /c DEL Drive:\Folder\*.*
Do More Stuff
This will work
If you have a SubFolder in your Directory it will not delete the SubFolder or the contents of the subfolder, but it will do what you asked for
Hope this helps
Code: Select all
Label>StartLookingForNewFile
Wait>1
let>files=0
let>FN=0
GetFileList>C:\testing\*.*,files
Separate>files,;,file_names
Repeat>FN
Let>FN=FN+1
StringReplace>file_names_%FN%,C:\testing\,,file_name
Label>LoopTillNameCount
IfFileExists>C:\testing\%file_name%,DeleteTheFile,NextLine
SRT>DeleteTheFile
DeleteFile>C:\testing\%file_name%
END>DeleteTheFile
Label>NextLine
Until>FN,file_names_count
Label>END
Aaron
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact: