Re: Recursive Find and Delete Droplet
Re: Recursive Find and Delete Droplet
- Subject: Re: Recursive Find and Delete Droplet
- From: Emmanuel <email@hidden>
- Date: Wed, 5 Mar 2003 17:45:43 +0100
At 3:49 PM +0100 05/03/03, Phil Suessenguth wrote:
I work in a mixed environment with Macs (OS-X/9) and (mostly) Windows servers.
When copying to the windows servers we often encounter file not
found errors and the transfer was aborted. It finally turned out,
that the culprit were 0kByte Icon files that happen to be in some
folders.
To make it as simple as possible for all non-technical users, I
would like to create a droplet that cleans the folder dropped on it
off all (0kB) Icon files.
Here are a few hints:
- the "open x" handler of the droplet provides your script with a
reference to the file(s) that were dropped, as the "x" variable. You
get that as a list of file references, or as a file reference
- you get the list of the items that are contained in a given folder
"theFolder" (supposedly given as a string) with:
---------------------------
list folder alias theFolder
---------------------------
or
---------------------------
list folder alias theFolder without invisibles
---------------------------
- therefore, you loop on the paths of the files contained in the folder with:
set theList to (list folder alias theFolder)
repeat with theItem in theList
set thePath to theFolder & theItem
-- process thePath
end
- to know whether some item is a folder, use "info for":
set isAFolder to folder of (info for alias thePath)
- finally, once you make sure that an item is a folder, just "try" to
delete its "Icon" file (you are aware that the file name ends with a
CR, aren't you) (if there is no such file, the script line will error
silently)
try
tell application "Finder" to delete alias (thePath & "Icon" & return)
end try
- also, though I did not test it, I'm afraid Michelle's script won't
work as such. "files of something" will not work as written.
Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.