delete all files

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
link76
Posts: 99
Joined: Fri Nov 04, 2011 1:52 pm

delete all files

Post by link76 »

hello,
how can I delete all the files bat?

don't work

Code: Select all

delete file mypath&"/*.bat"
thanks you
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: delete all files

Post 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
shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: delete all files

Post 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
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: delete all files

Post by Klaus »

Ha, I beat you with one line less! :-D
shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: delete all files

Post by shaosean »

oh yeah, the filter command ;-)
Post Reply