Re: trouble with finder
Re: trouble with finder
On Feb 5, 2011, at 8:33am, tom wible wrote:
> nevermind, i found a workaround:
>
> set f to (POSIX file ppath)
> tell application "Finder" to move f to trash
Here's a few comments.
Do you have a good reason for switching from alias to posix path? Alias is the most reliable reference to files in AppleScript, and easily converts to posix when needed.
Your entire script could be reduced to about four lines if you stayed with alias.
When you coerce an alias to POSIX Path, the class of the value is text.
You can coerce that to a POSIX File with 'as posix file' and the class is 'furl'
Finder will handle that coercion itself, but not in the format you're sending it.
Either of these should work.
tell application "Finder" to delete (ppath) as POSIX file
tell application "Finder" to delete (path)
HTH,
ES
Here's a modified version of your script with these changes
--------
set these_files to choose file with multiple selections allowed
set PpathList to {}
repeat with f in these_files
log "f=" & f
set thisFile to POSIX path of f
log class of thisFile -->text
set end of PpathList to thisFile
end repeat
try
repeat with ppath in PpathList
log "ppath1=" & ppath
set ppath to (contents of ppath) as string --this line is not needed, ppath is already text. Also use ' as text' rather than as string
set myPosix to ppath as POSIX file
log class of myPosix --furl
tell application "Finder" to delete (ppath) as POSIX file
-- This coerces the string to posix file.
end repeat
on error msg
log msg
end try
try
repeat with ff in these_files
log "ff=" & ff
tell application "Finder" to move ff to trash
end repeat
on error msg
log msg
end try
_______________________________________________
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