Tuesday, July 14, 2020

#1 2002-12-09 02:32:55 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Info for command

Dear,

I a'm trying to get info to check if a selected item is a folder or a file
but i get an error and i dont seem to find the right syntax for it.
does anyone have a solution

the script:

tell application "Finder"
    activate
    set selectedFolder to (choose folder)
    set selectedFoldername to name of selectedFolder
    --return selectedFoldername & " - " & selectedFolder
   
    set info_for to info for selectedFolder
    if folder of info_for is true and package folder of info_for is false then
        display dialog "It's a folder"
    else
        display dialog "It's a file or package."
    end if
   
end tell


the error
Can't get folder of ...[/b][b]


One mans trash is another mans treasure


Filed under: Finder

Offline

 

#2 2002-12-09 07:03:25 am

Rob
Member
From:: Ohio, USA
Registered: 2002-11-20
Posts: 1886

Re: Info for command

I a'm trying to get info to check if a selected item is a folder or a file but i get an error and i dont seem to find the right syntax for it.
does anyone have a solution


For starters, you don't need to use the Finder for this. Besides taking the Finder out of the script, I've made a couple of small changes which should yield the proper result. It works on my system (10.2.2).  smile

Applescript:

set selectedFolder to (choose folder)
--set selectedFolder to (choose file)
--return selectedFoldername & " - " & selectedFolder

set info_for to info for selectedFolder
set selectedFoldername to name of info_for

if folder of info_for is true and package folder of info_for is false then
   display dialog "It's a folder"
else
   display dialog "It's a file or package."
end if

Offline

 

#3 2002-12-09 11:07:17 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Info for command

I'd use Finder for this; it's faster and a bit more backwards-compatible than 'info for'. (Note that Finder recognises application packages as application files.)

Applescript:

tell application "Finder" to set isFolder to (class of item anAlias is folder)

You might also want to check if it's a disk:

Applescript:

tell application "Finder" to set isDisk to (class of item anAlias is disk)

(OS9.2.2, AS1.6; OS10.2.2, AS1.9)


One mans trash is another mans treasure


Filed under: Finder

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)