Re: whose class is folder...
Re: whose class is folder...
- Subject: Re: whose class is folder...
- From: Shane Stanley <email@hidden>
- Date: Sat, 07 Apr 2018 11:50:49 +1000
On 7 Apr 2018, at 10:47 am, Stockly, Ed <email@hidden> wrote:
>
> Let me save you some time and frustration:
That works, but it's locale dependent -- run it on a system where the the name
for a folder is different and it fails. Given that the OP is a translator, at
the very least that's likely to offend his professional sensibilities.
You could use "info for". I'm no fan of using deprecated commands, but it does
still work.
OTOH, I'd do it using AppleScriptObjC:
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
tell application "Finder" to set myFinderItems to the selection as alias list
set selectedFolders to foldersInListOfItems(myFinderItems)
on foldersInListOfItems(listOfAliasesOrFiles)
set selectedFolders to {}
repeat with aFile in listOfAliasesOrFiles
set aURL to (current application's |NSURL|'s
fileURLWithPath:(POSIX path of aFile))
-- is it a directory?
set {theResult, theValue} to (aURL's
getResourceValue:(reference) forKey:(current application's NSURLIsDirectoryKey)
|error|:(missing value))
if theValue as boolean then
-- is it a package?
set {theResult, theValue} to (aURL's
getResourceValue:(reference) forKey:(current application's NSURLIsPackageKey)
|error|:(missing value))
if not theValue as boolean then -- must be folder
set end of selectedFolders to aURL as «class
furl» -- convert URL to file
end if
end if
end repeat
return selectedFolders
end foldersInListOfItems
A bit more code, a bit faster.
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
_______________________________________________
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