Page 1 of 1
delete all files
Posted: Thu Aug 08, 2013 8:24 am
by link76
hello,
how can I delete all the files bat?
don't work
thanks you
Re: delete all files
Posted: Thu Aug 08, 2013 11:11 am
by Klaus
Hi link76,
you need to use a "repeat loop", something like this:
Code: Select all
...
## 1. navigate to target folder
set the folder to mypath
## 2. get all the files in htis folder
put the files into tFiles
## 3. FILTER out only *.bat files
filter tFiles with "*.bat"
## 4. now loop through the files and delete them
repeat with i = 1 to the num of lines of tFiles
delete file (line i of tFiles)
end repeat
...
Best
Klaus
Re: delete all files
Posted: Thu Aug 08, 2013 11:13 am
by shaosean
Code: Select all
set the defaultFolder to "PATH_TO_FILES"
put the files into tFiles
repeat for each line tFileName in tFiles
if (character -4 to -1 of tFileName = ".bat") then
delete file tFileName
end if
end repeat
Re: delete all files
Posted: Thu Aug 08, 2013 2:51 pm
by Klaus
Ha, I beat you with one line less!

Re: delete all files
Posted: Thu Aug 08, 2013 9:16 pm
by shaosean
oh yeah, the filter command
