Re: Listing Files, Deleting Files
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