• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Listing Files, Deleting Files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Listing Files, Deleting Files


  • Subject: Re: Listing Files, Deleting Files
  • From: Stan Cleveland <email@hidden>
  • Date: Fri, 07 Aug 2009 13:45:33 -0700
  • Thread-topic: Listing Files, Deleting Files

Title: Re: Listing Files, Deleting Files
On 8/7/09 1:25 PM, "Andrew P" wrote:

I have an interesting problem here. I need to compress a folder into a ZIP file. Before I do this, I need a script that will delete the .DSStore and other hidden files in the folder. So far I am only stuck on one thing, how to list the files in the folder, and delete the invisible ones, without touching the other files. Any help?

Hi Andrew,

This should do what you need:

set
theFolder to ("" & (path to desktop) & "TestFolder:") -- or wherever

set allFiles to list folder theFolder
set visibleFiles to list folder theFolder without invisibles
repeat
with i from 1 to (count allFiles)
   set thisFile to item i of allFiles
   if thisFile is not in visibleFiles then -- it's invisible
       tell application "System Events" to delete file ( theFolder & thisFile)
   end if
end
repeat

Stan C.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Listing Files, Deleting Files (From: Andrew P <email@hidden>)

  • Prev by Date: Listing Files, Deleting Files
  • Next by Date: Re: Listing Files, Deleting Files
  • Previous by thread: Listing Files, Deleting Files
  • Next by thread: Re: Listing Files, Deleting Files
  • Index(es):
    • Date
    • Thread