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
-
Alex_CTZ
- Posts: 21
- Joined: Fri Jan 10, 2014 11:38 pm
Post
by Alex_CTZ » Fri Apr 18, 2014 4:00 pm
How can i delete a folder with item in it.
I know about the
but that only seems to work when it is empty.
Also,
For some reason open file and launch file
wont open a .log file
how can I make it so when a user presses a button it opens a file?
-Thanks
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Fri Apr 18, 2014 4:16 pm
Hi Alex,
If you change your title into some descriptive text, you'll get more help.
You need to delete the files in the folder before you can delete the folder.
Use a different file extension or use different syntax:
Code: Select all
launch documentPath with applicationPath
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Alex_CTZ
- Posts: 21
- Joined: Fri Jan 10, 2014 11:38 pm
Post
by Alex_CTZ » Fri Apr 18, 2014 4:37 pm
Mark wrote:Hi Alex,
If you change your title into some descriptive text, you'll get more help.
You need to delete the files in the folder before you can delete the folder.
Use a different file extension or use different syntax:
Code: Select all
launch documentPath with applicationPath
Kind regards,
Mark
Is there a way to delete each file without specifying the name and path. As there are over 500 files that names change :/
-Thanks
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Fri Apr 18, 2014 4:48 pm
Hi Alex,
Alex_CTZ wrote:Is there a way to delete each file without specifying the name and path. As there are over 500 files that names change :/
use a repeat loop over a list of "the files"!
Something like this:
Code: Select all
...
put "C:/pathHere" into tPath
put the folder into tOldDirectory
set the folder to tPath
put the files into tFiles
repeat for each line i in tFiles
delete file i
end repeat
set folder to tOldDirectory
delete folder tPath
...
Best
Klaus
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Fri Apr 18, 2014 4:51 pm
Alex,
suppose that the variable myPath contains the path to the folder. You can use this script to delete all files:
Code: Select all
set the itemDel to slash
set the defaultFolder to myPath
put the files into myFiles
filter myFiles without "."
filter myFiles without ".."
repeat for each line myFile in myFiles
delete file myFile
end repeat
set the defaultFolder to item 1 to -2 of myPath
delete folder myPath
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Fri Apr 18, 2014 4:52 pm
Klaus,
What if the old directory is the same as the folder that is to be deleted?
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Klaus
- Posts: 14177
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Fri Apr 18, 2014 4:54 pm
Hi Mark,
Mark wrote:What if the old directory is the same as the folder that is to be deleted?

well, that wouldn't affect me, personally, at all!
Best
Klaus
-
Alex_CTZ
- Posts: 21
- Joined: Fri Jan 10, 2014 11:38 pm
Post
by Alex_CTZ » Fri Apr 18, 2014 4:58 pm
Thanks so much all!, I am really happy I chose Livecode to start out with as the help community is the best

Thanks again
-Alex