How to delete all text files in the path:specialFolderPath("documents")

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
liveCode
Posts: 119
Joined: Sun Oct 17, 2021 5:53 pm

How to delete all text files in the path:specialFolderPath("documents")

Post by liveCode » Wed Apr 20, 2022 4:58 pm

How to delete all text files in the path:

Code: Select all

specialFolderPath("documents")

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to delete all text files in the path:specialFolderPath("documents")

Post by Klaus » Wed Apr 20, 2022 6:24 pm

Look up:
delete
files("name of folder with the files")
filter

If your text files have the suffix TXT:

Code: Select all

on mouseUp 
   
   ## Save some typing by puttin the path into a variable:
   put specialfolderpath("documents") & "/" into tDocFolder
   ## specialfolderpath() names do not come with a trailing SLASH!
   
   ## Get a list of all files in that folder:
   put files(tDocFolder) into tFiles
   
   ## Exclude all non txt fiels:
   filter tFiles with "*.txt"
   
   ## Now delete all the files in the list of files:
   repeat for each line tFile in tFiles
   
      ## Create full path to the files and delete them:
      delete file (tDocFolder & tFile)
   end repeat
end mouseUp
I recommend to NOT use or test this script on your desktop machine! :D


Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to delete all text files in the path:specialFolderPath("documents")

Post by FourthWorld » Wed Apr 20, 2022 6:48 pm

liveCode wrote:
Wed Apr 20, 2022 4:58 pm
How to delete all text files in the path:

Code: Select all

specialFolderPath("documents")
Respectfully, your good nature as expressed here before suggests to me that you don't actually want to do that. If you were successful you'd eliminate most or all of the user-made content from the machine.

Can you tell us a bit more about what you want to accomplish?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to delete all text files in the path:specialFolderPath("documents")

Post by Klaus » Wed Apr 20, 2022 7:13 pm

Judging from all of his earlier postings I am sure he means MOBILE (Android) without explicitely mentioning it.
We know how miserly he is with more info. :-)

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”