Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JimmyBoyB

macrumors newbie
Original poster
Nov 6, 2013
15
0
Hi,

First off, I am very new to AppleScript / Automator so this is a learning curve for me.

I am trying to create a script that simply moves selected files into a new folder.

If I run the following code on a file(s) on the local mac disk, the script will run as expected. If I run it on a file within a share on my NAS (Synology, DSM v6) then I get an error of "Finder got an error: Can't get folder "foldername" of disk "disk"." ("foldername" & "disk" would specify the file/folder name and disk respectively)

The thing thats really confusing me is that, while writing / testing the script, I was using files on the share. I then done some other stuff (life stuff, not mac / nas), then come back to carry on from where I was, and now get this error I don't know how to work around.

The script will fail at the line:
set fileName to name of item 1 of selected_items

Any help / suggestions would be greatly appreciated.

Code:
try
  
    tell application "Finder" to set the this_folder to (folder of the front window) as alias
  
on error -- no open windows
    set the this_folder to path to desktop folder as alias
  
end try

tell application "Finder"
  
    -- grab the selected files and place them in a variable
    set selected_items to selection
  
    set fileName to name of item 1 of selected_items
  
    -- prompt for a folder name
    set thefoldername to text returned of (display dialog "Folder name:" default answer fileName)
  
    -- make the new folder in the same directory
    set theFolder to (make new folder at this_folder with properties {name:thefoldername})
  
    -- loop through selected items
    repeat with x in selected_items
        move x to theFolder
    end repeat
  
end tell
 
Last edited:
In this line:
Code:
    set selected_items to selection
the Finder's frontmost window must have something selected. If nothing is selected in that window, or the Finder has no windows open and nothing selected on the desktop, then the selection will be empty. If the selection is empty, then selected_items will be an empty list. An empty list contains no items, so there can't be an item 1 of selected_items.

Paste this into AppleScript Editor:
Code:
tell application "Finder" to get selection
then run it. The result will depend on what window is active in Finder, and what (if anything) has been selected in that window.

I recommend that you try opening different windows in Finder, then making different selections in each window, then switching back to AppleScript Editor and running the line again. You should see how the result varies.

Then deselect everything in a Finder window and run the script. You should see an empty list.

You should also see an empty list if no Finder windows are active. Click once on the desktop behind all windows. Notice the title bar of any active window changes, and any selected items in that window change selection color. Now run the script again.


I suspect it was working before because of what you had selected in Finder's active window. If you want it to work again, select something in Finder, and make its window active.

If you don't want your script to rely on selecting something first in Finder, then you need to change the line that relies on selection. Probably you'll need a dialog that lets you select files or folders to be moved. That's a choose file or choose folder command:
https://developer.apple.com/library...html#//apple_ref/doc/uid/TP40000983-CH216-SW4
 
Thanks for the reply, and sorry for the delay.

I understand what you are saying, but I don't think this is the cause of my issue.

I am using this as a service, and therefore there should always be a selection (theoretically).

However, I took on board what you said as its something I wanted to do anyway and also cleaned up the code, but the problem continues.

Again... this works every time for me when I am choosing a file that is on the local hard disk. As soon as I try to use this on a file located on the NAS (AFP share) then the script throws an error (Can’t make «class ctnr» of alias "home:temp:myfile:" into type string.) and fails on the line (
set filePath to container of fileAlias as string)

I have also tried with posix paths (just to try) but still no success.

As previously stated, I am new to AppleScript (and also OS X) so I'm hoping it's something daft I am doing, but I can't help but think it's something related to the NAS (such as file permissions etc, but I'm not sure)

Anyway, heres the revised code.

Code:
tell application "Finder"
   
    -- Check a selection has been made
    set sel to (get selection)
    if sel = {} then
        return
    end if
   
    -- Define variables used   
    set selectedItems to selection
    set fileAlias to item 1 of selectedItems as alias
    set filePath to container of fileAlias as string
   
    -- Get both filename (with extension) & extension   
    tell application "System Events" to tell disk item (fileAlias as text) to set {fileName, fileExtension} to {name, name extension}
   
    -- Trim filename of extension
    if fileExtension is not "" then
        set fileName to text 1 thru -((count fileExtension) + 2) of fileName
        set fileExtension to "." & fileExtension
    end if
   
    -- prompt for a folder name
    set newFolderName to text returned of (display dialog "Folder name:" default answer fileName)
   
    if exists filePath & newFolderName then
        display alert "The destination folder already exists." message "Cannot move items into a folder that already exists." buttons "Ok" as critical
        return
    end if
   
    -- make the new folder in the same directory
    set createdFolder to (make new folder at filePath with properties {name:newFolderName})
   
    -- loop through selected items
    repeat with x in selectedItems
        move x to createdFolder
    end repeat
end tell
 
I can't think of any reason it would fail with a NAS, unless there's something odd about the pathname or access permissions. At this point, there's no way to tell what's causing the problem.

Let's cut the problem down and work with that. Having a working example, even a simplified one, is the way to make progress. Examples that don't work have to be made to work first.

Run this code in AppleScript Editor:
Code:
tell application "Finder"

    set _items to selection
    log "Items: " & (count of _items)

    set foo to item 1 of _items
    log "Item 1: " & foo

    set bar to foo as alias -- force to alias
    log "bar: " & bar

    log "path: " & (POSIX path of bar)

end tell
Make sure the Finder's selection is at least one file on your NAS share.

Copy and paste the complete output into a post here.

Here's complete example output from when I run the above on my machine here. This is output in an AppleScript Editor window.
Code:
tell application "Finder"
    get selection
    (*Items: 2*)
    get folder "Example-Browser-HTML-saved" of folder "Browser" of folder "Example" of disk "Work"
    (*Item 1: Work:Example:Browser:Example-Browser-HTML-saved:*)
    get folder "Example-Browser-HTML-saved" of folder "Browser" of folder "Example" of disk "Work"
    (*bar: Work:Example:Browser:Example-Browser-HTML-saved:*)
    (*path: /Volumes/Work/Example/Browser/Example-Browser-HTML-saved/*)
end tell

I need to see your real complete pathnames, not elided or condensed versions. If you're wary of posting pathnames, then make a new share on your NAS named "Example", put some files in it, and use that. I'll ask you to run some Terminal command-lines, too, so be prepared to do that (first one below).

Oh, and exactly what protocol are you connecting to your NAS with? Copy and paste this command into a Terminal.app window, then copy and paste the output into a post here:
Code:
mount

Saying that you tried Posix paths without showing the code doesn't clarify anything. We could guess what code you wrote, and guess what errors you got, but guessing is the worst possible way of debugging code. If you have concrete code, please post it, along with the exact text of the errors. If you no longer have the actual code, don't worry, we may get there eventually.
 
I can't think of any reason it would fail with a NAS, unless there's something odd about the pathname or access permissions. At this point, there's no way to tell what's causing the problem.

Let's cut the problem down and work with that. Having a working example, even a simplified one, is the way to make progress. Examples that don't work have to be made to work first.

Run this code in AppleScript Editor:
Code:
tell application "Finder"

    set _items to selection
    log "Items: " & (count of _items)

    set foo to item 1 of _items
    log "Item 1: " & foo

    set bar to foo as alias -- force to alias
    log "bar: " & bar

    log "path: " & (POSIX path of bar)

end tell
Make sure the Finder's selection is at least one file on your NAS share.

Copy and paste the complete output into a post here.

Here's complete example output from when I run the above on my machine here. This is output in an AppleScript Editor window.
Code:
tell application "Finder"
    get selection
    (*Items: 2*)
    get folder "Example-Browser-HTML-saved" of folder "Browser" of folder "Example" of disk "Work"
    (*Item 1: Work:Example:Browser:Example-Browser-HTML-saved:*)
    get folder "Example-Browser-HTML-saved" of folder "Browser" of folder "Example" of disk "Work"
    (*bar: Work:Example:Browser:Example-Browser-HTML-saved:*)
    (*path: /Volumes/Work/Example/Browser/Example-Browser-HTML-saved/*)
end tell

I need to see your real complete pathnames, not elided or condensed versions. If you're wary of posting pathnames, then make a new share on your NAS named "Example", put some files in it, and use that. I'll ask you to run some Terminal command-lines, too, so be prepared to do that (first one below).

Oh, and exactly what protocol are you connecting to your NAS with? Copy and paste this command into a Terminal.app window, then copy and paste the output into a post here:
Code:
mount

Saying that you tried Posix paths without showing the code doesn't clarify anything. We could guess what code you wrote, and guess what errors you got, but guessing is the worst possible way of debugging code. If you have concrete code, please post it, along with the exact text of the errors. If you no longer have the actual code, don't worry, we may get there eventually.

Wow, thanks for taking so much time for the advice!

Heres the output from AppleScript with the script you posted.

Code:
tell application "Finder"
    get selection
    (*Items: 1*)
    get document file "tutorial.pdf" of folder "temp" of disk "home-1"
    (*Item 1: home-1:temp:tutorial.pdf*)
    get document file "tutorial.pdf" of folder "temp" of disk "home-1"
    (*bar: home:temp:tutorial.pdf*)
    (*path: /Volumes/home-1/temp/tutorial.pdf*)
end tell

heres the mount (I have changed my personal details to User1 / User2 - Two users on this mac, both with a home folder on the NAS). I am logged in as "User2" / "user2".

Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

//User1@DiskStation.local/home on /Volumes/home (afpfs, nodev, nosuid, mounted by user1)
//User2@DiskStation.local/home on /Volumes/home-1 (afpfs, nodev, nosuid, mounted by user2)


re: posix paths. I did not save the code as it didn't work, and to be honest I'm not sure what difference it makes. I think posix will return "path:file" and non-posix will return "path/file", but I'm not sure where consideration of these two different methods need to be taken into consideration, or if they can be used interchangeably.

Thanks again for the help.
 
Last edited:
Try this. Again, post complete output.
Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)
 
    set _first to (first item of _items) as alias
    log "First: " & _first
    
    set _container to (folder of _first) as alias
    set _fname to name of _first
    tell application "System Events" to set _fextn to name extension of _first
 
    log "Container: " & _container
    log "Name: " & _fname
    log "Extn: " & _fextn

end tell

The leading '_' is to minimize how much I type for variable names. It has no other significance, except to ensure the variable name doesn't conflict with a keyword. For example, you can't name a variable 'first' or 'container' because those are keywords.
 
Try this. Again, post complete output.
Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)

    set _first to (first item of _items) as alias
    log "First: " & _first
   
    set _container to (folder of _first) as alias
    set _fname to name of _first
    tell application "System Events" to set _fextn to name extension of _first

    log "Container: " & _container
    log "Name: " & _fname
    log "Extn: " & _fextn

end tell

The leading '_' is to minimize how much I type for variable names. It has no other significance, except to ensure the variable name doesn't conflict with a keyword. For example, you can't name a variable 'first' or 'container' because those are keywords.

Code:
tell application "Finder"
    get selection
    (*Items: 1*)
    get document file "tutorial.pdf" of folder "temp" of disk "home-1"
    (*First: home:temp:tutorial.pdf*)
    get folder of alias "home:temp:tutorial.pdf"
Result:
error "Can’t make «class cfol» of alias \"home:temp:tutorial.pdf\" into type alias." number -1700 from «class cfol» of alias "home:temp:tutorial.pdf" to alias
 
Code:
tell application "Finder"
    get selection
    (*Items: 1*)
    get document file "tutorial.pdf" of folder "temp" of disk "home-1"
    (*First: home:temp:tutorial.pdf*)
    get folder of alias "home:temp:tutorial.pdf"
Result:
error "Can’t make «class cfol» of alias \"home:temp:tutorial.pdf\" into type alias." number -1700 from «class cfol» of alias "home:temp:tutorial.pdf" to alias
That's interesting. It seems to be getting confused between this line:
get document file "tutorial.pdf" of folder "temp" of disk "home-1"​

and this line:
(*First: home:temp:tutorial.pdf*)
The first shows the file residing on disk home-1, but the second shows it trying to access the file on "home" instead of on "home-1".

Try this:
Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)
   
    set _first to (first item of _items) as alias
    log "First: " & _first
   
    set _path to POSIX path of _first
    set _fname to name of _first
   
    log "Path: " & _path
    log "Name: " & _fname
   
end tell
 
Don't know if it helps, but right clicking on the file, and "Get Info", returns this path:

afp://DiskStation.local/home/temp/tutorial.pdf
 
Last edited:
Try this:
Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)
   
    set _first to first item of _items
    log "First: " & _first
   
    log "Disk: " & (disk of _first)
   
end tell
 
Also, "Info" for the mount shows this



I notice I have custom access, and everyone "No Access" ?
[doublepost=1473218430][/doublepost]
Try this:
Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)
  
    set _first to first item of _items
    log "First: " & _first
  
    log "Disk: " & (disk of _first)
  
end tell
Code:
tell application "Finder"
    get selection
    (*Items: 1*)
    get document file "tutorial.pdf" of folder "temp" of disk "home-1"
    (*First: home-1:temp:tutorial.pdf*)
    get disk of document file "tutorial.pdf" of folder "temp" of disk "home-1"
    (*Disk: home-1:*)
end tell
 
Also, "Info" for the mount shows this



I notice I have custom access, and everyone "No Access" ?
That doesn't tell me anything useful. I'd have to formulate a Terminal command line to get useful information, and I'm not at that point yet. I already got enough info from the output you posted from the 'mount' command.

What are the results from the latest script?
 
That doesn't tell me anything useful. I'd have to formulate a Terminal command line to get useful information, and I'm not at that point yet. I already got enough info from the output you posted from the 'mount' command.

What are the results from the latest script?
see above
[doublepost=1473218664][/doublepost]
see above

I have to go to bed now (its 4:30am).

Thanks for all the help so far, hopefully we can pick up tomorrow.
 
Code:
tell application "Finder"
    get selection
    (*Items: 1*)
    get document file "tutorial.pdf" of folder "temp" of disk "home-1"
    (*First: home-1:temp:tutorial.pdf*)
    get disk of document file "tutorial.pdf" of folder "temp" of disk "home-1"
    (*Disk: home-1:*)
end tell
I thought it was going to be that. That's an obstacle, because it means I'll have to make a work environment that's a much closer mirror to what you're using. I'm pretty sure I can do that with a couple of disk images, but it will take me time to set it all up and start poking around with it. I'll have to get back to it tomorrow morning.

FWIW, I don't think the problem is with the NAS per se, but with the names of the mounted disks. Referring back to your earlier post of output:

//User1@DiskStation.local/home on /Volumes/home (afpfs, nodev, nosuid, mounted by user1)
//User2@DiskStation.local/home on /Volumes/home-1 (afpfs, nodev, nosuid, mounted by user2)​

I think the problem lies here, where two users seem to have the same NAS folder mounted as two separate shares. AppleScript seems to be getting confused by this state of affairs.

It might work if you unmounted both shares (both users), and then mounted the sharepoint using only the active user you're running the script from. This should make it mount to "/Volumes/home", which you can check using the 'mount' command. At that point, there's only one mounted share, and no possible confusion over "home" vs. "home-1". You can try the earlier scripts (including your original one) and see what happens. Post any interesting results.

Regardless of what you try, and whether it works or not, I'm going to setup the test environment and see if I can find a way to resolve this. I think a resolution is possible, but I'm going to have to poke around with AppleScript to figure it out.

EDIT:
I was editing while you were posting your sign-off for the night message.

Agreed we'll pick it up in the morning.
 
Last edited:
I thought it was going to be that. That's an obstacle, because it means I'll have to make a work environment that's a much closer mirror to what you're using. I'm pretty sure I can do that with a couple of disk images, but it will take me time to set it all up and start poking around with it. I'll have to get back to it tomorrow morning.

FWIW, I don't think the problem is with the NAS per se, but with the names of the mounted disks. Referring back to your earlier post of output:

//User1@DiskStation.local/home on /Volumes/home (afpfs, nodev, nosuid, mounted by user1)
//User2@DiskStation.local/home on /Volumes/home-1 (afpfs, nodev, nosuid, mounted by user2)​

I think the problem lies here, where two users seem to have the same NAS folder mounted as two separate shares. AppleScript seems to be getting confused by this state of affairs.

It might work if you unmounted both shares (both users), and then mounted the sharepoint using only the active user you're running the script from. This should make it mount to "/Volumes/home", which you can check using the 'mount' command. At that point, there's only one mounted share, and no possible confusion over "home" vs. "home-1". You can try the earlier scripts (including your original one) and see what happens. Post any interesting results.

Regardless of what you try, and whether it works or not, I'm going to setup the test environment and see if I can find a way to resolve this. I think a resolution is possible, but I'm going to have to poke around with AppleScript to figure it out.

EDIT:
I was editing while you were posting your sign-off for the night message.

Agreed we'll pick it up in the morning.

I agree, there appears to be some confusion with home / home-1.

I have gone through the procedure of un-mounting and re-mounting so that I am the only user, and just "home" being mounted, as follows (this time, I am User1)

Code:
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
//User1@DiskStation.local/home on /Volumes/home (afpfs, nodev, nosuid, mounted by user1)


then I run the code samples from last night
Code:
tell application "Finder"

    set _items to selection
    log "Items: " & (count of _items)

    set foo to item 1 of _items
    log "Item 1: " & foo

    set bar to foo as alias -- force to alias
    log "bar: " & bar

    log "path: " & (POSIX path of bar)

end tell

result
Code:
tell application "Finder"

    get selection

    (*Items: 1*)

    get document file "tutorial.pdf" of folder "temp" of disk "home"

Result:

error "Can’t make «class docf» \"tutorial.pdf\" of «class cfol» \"temp\" of «class cdis» \"home\" of application \"Finder\" into type Unicode text." number -1700 from «class docf» "tutorial.pdf" of «class cfol» "temp" of «class cdis» "home" to Unicode text



Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)

    set _first to (first item of _items) as alias
    log "First: " & _first

    set _path to POSIX path of _first
    set _fname to name of _first

    log "Path: " & _path
    log "Name: " & _fname

end tell

result
Code:
tell application "Finder"

    get selection

    (*Items: 1*)

    get document file "tutorial.pdf" of folder "temp" of disk "home"

Result:

error "Can’t make «class docf» \"tutorial.pdf\" of «class cfol» \"temp\" of «class cdis» \"home\" of application \"Finder\" into type alias." number -1700 from «class docf» "tutorial.pdf" of «class cfol» "temp" of «class cdis» "home" to alias



Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)

    set _first to first item of _items
    log "First: " & _first

    log "Disk: " & (disk of _first)

end tell

result
Code:
tell application "Finder"

    get selection

    (*Items: 1*)

    get document file "tutorial.pdf" of folder "temp" of disk "home"

Result:

error "Can’t make «class docf» \"tutorial.pdf\" of «class cfol» \"temp\" of «class cdis» \"home\" of application \"Finder\" into type Unicode text." number -1700 from «class docf» "tutorial.pdf" of «class cfol» "temp" of «class cdis» "home" to Unicode text

Thats the results.
[doublepost=1473250691][/doublepost]Im not sure if this information will help, but think I ought to give as much background information as possible in case it does turn out to be relevant. I done the following, BEFORE I wrote any scripts, so do not have a before / after comparison.

I use my mac for both personal and work. I wanted a method to keep work and personal separate (other than just a "personal" folder and "work" folder), so I had the idea of making two users for myself. One for work, one for personal. This is what you see as User1 & User2 / home & home-1.

Again, I'm new to OS X so I'm learning as I go. For both users on the mac I have used the same AppleID (as they are both for me, just different work done on the respective user account). The main reason I done this is I wanted to be able to use my purchased apps for both users, and I was under the assumption that the available apps to a user where determined by the AppleID used, but in hindsight it appears to be any user can access apps on the machine, meaning I did not need to use the same AppleID on two different user accounts.

I was a little uncomfortable doing the above (2 User Accounts, 1 AppleID) but thought I would try, and everything appears to be working "ok" (ish). In hindsight I may remove the AppleID from one of the User Account's if I don't need it.

Do you have any advice on this? Good idea / bad idea / relevant / no relevance to topic.

The reason I mention it is, I do have the occasional issue since doing this (at least, I never had the problems listed below, beforehand)
1) Sometimes system preferences pops up asking me to enter my iCloud password
2) Sometimes mail pops up asking me for my password
3) Sometimes I cannot access ANY file on iCloud through Finder or Apps (returns a (null) reference)). The only resolve to this particular issue I have found is to completely restart the machine.

In additional to all this I took the opportunity to get parity between users on the mac and users on the NAS (i.e., for every user on the mac, there is a respective user on the NAS), this included me making an "Administrator" account on the Mac, and demoting myself to a "Standard" user from an "Administrator" in macs system preferences.

This made some sense to me as I would like to be able to use the mac / NAS as a normal user without any administritive privilliges, and leave all the administritive tasks to the Administrator user on the mac / NAS.

I hope this may of been of some relevance, and not a waste of your reading time.

Thanks Again!
 
Last edited:
With the above in mind, I have switched to the "Administrator" account on the mac, and recreated the same folder structure for this user as we were using previously, for some consistency.

Code:
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
//User1@DiskStation._afpovertcp._tcp.local./Time%20Machine%20Backups on /Volumes/Time Machine Backups (afpfs, nobrowse)
//admin@DiskStation.local/homes on /Volumes/homes (afpfs, nodev, nosuid, mounted by Administrator)
//admin@DiskStation.local/home on /Volumes/home (afpfs, nodev, nosuid, mounted by Administrator)
/dev/disk2s2 on /Volumes/Time Machine Backups 1 (hfs, local, nodev, nosuid, journaled, nobrowse)

run
Code:
tell application "Finder"

    set _items to selection
    log "Items: " & (count of _items)

    set foo to item 1 of _items
    log "Item 1: " & foo

    set bar to foo as alias -- force to alias
    log "bar: " & bar

    log "path: " & (POSIX path of bar)

end tell

result
Code:
(*Items: 1*)

Result:

error "Can’t make «class docf» \"tutorial.pdf\" of «class cfol» \"temp\" of «class cdis» \"home\" of application \"Finder\" into type Unicode text." number -1700 from «class docf» "tutorial.pdf" of «class cfol» "temp" of «class cdis» "home" to Unicode text

On a side note, I wanted to ensure that the "home" share was using the admin login credentials of the NAS, so tried to "Eject" the "home" folder (so I could remount and enter login credentials), but the share comes back after hitting "Eject". If I "Eject" about 5 or 6 times in a row, then the share appears to finally eject. However, when reconnecting to server (Finder > Go > Connect to server... afp://DiskStation.local) it does not ask me for any credentials (maybe it's using credentials from my KeyChain?).

Sorry if I have potentially gone off on a complete tangent, but wanted to get all these little niggly things off my chest as they have been bugging me, and they MAY have some relevance to the current problem.
 
Last edited:
Thanks for the test-runs and extra info.

I don't think the multiple users is hurting or helping. It may have an effect when it comes to permissions on the NAS, but I'm not sure.

The NAS appears to be using AFP protocol, not SMB, and I have a second Mac here that serves using AFP, so if it becomes necessary I'm pretty sure I can setup multiple accounts and connect to my server pretending to be a NAS. I'm going to start with disk-images, though, because it's simpler. If it doesn't show the problem, I'll try AFP accounts.


One thing I don't recall you mentioning is your OS version. Please post that so I know what you're running on.
 
Try this, as User1, with only one mount to NAS "home". Paste it into a Terminal window:
Code:
mount ; ls -na /Volumes/home* ; id
 
I set things up with multiple disk-images having the same name. They all worked.

I then tried mounting a share from my other Mac, serving under the AFP protocol. That worked, too.

I did this under both 10.8 Mountain Lion and under 10.11.3 El Capitan, with no problems.


The most interesting of the tests and results you ran early today is this one:

Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)

    set _first to first item of _items
    log "First: " & _first

    log "Disk: " & (disk of _first)

end tell

--- Results ---
tell application "Finder"

    get selection

    (*Items: 1*)

    get document file "tutorial.pdf" of folder "temp" of disk "home"

Result:

error "Can’t make «class docf» \"tutorial.pdf\" of «class cfol» \"temp\" of «class cdis» \"home\" of application \"Finder\" into type Unicode text." number -1700 from «class docf» "tutorial.pdf" of «class cfol» "temp" of «class cdis» "home" to Unicode text
This script is pretty simple stuff. It should be able to convert the _first object into a string to log it, but it's unable to do that, according to the error message. Error number -1700 means a failure to convert to a requested type.

Below is an even simpler script I'd like you to try in AppleScript Editor.

When you post the results, click the "Replies" icon in AppleScript's Log pane, rather than just the "Events" logging icon (hover the cursor over the little tool icons to see what each one means). "Replies" should show the types of the returned objects, in addition to the logged text and logged results.
Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)

    set _first to first item of _items
    log "Disk: " & (disk of _first)
    log "Fold: " & (folder of _first)
    log "Name: " & (name of _first)
end tell
 
Ok, so I have been using the machine today with both users, and User1 is now back on home-1, the results follow. I will now restart my machine, unmount / remount to get back to being on "home" to see if the results are different.

Code:
mount ; ls -na /Volumes/home* ; id

result
Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

//User1@DiskStation.local/home on /Volumes/home-1 (afpfs, nodev, nosuid, mounted by user1)

total 72

drwxrwxrwx  1 501  20   1724  4 Sep 19:17 #recycle

drwx------@ 1 501  20    466  7 Sep 15:29 .

drwxrwxrwt@ 4 0    80    136  7 Sep 20:55 ..

-rwxrwxrwx@ 1 501  20  32772  7 Sep 15:31 .DS_Store

drwxrwxrwx@ 1 501  20    264 10 Jul 19:49 .TemporaryItems

drwxrwxrwx  1 501  20   1996  3 Sep 23:51 app content

drwxrwxrwx  1 501  20    264 22 Aug 14:45 collections

drwxrwxrwx  1 501  20    264  4 Sep 18:50 downloads

drwxrwxrwx  1 501  20   1350  6 Sep 23:20 my work

drwxrwxrwx  1 501  20    264  4 Sep 20:06 photo

drwxrwxrwx  1 501  20    704 14 Aug 19:45 repository

drwxrwxrwx  1 501  20   1044 21 Aug 13:56 sorted

drwxrwxrwx  1 501  20    398 28 Aug 21:04 sorting

drwxrwxrwx  1 501  20    772  7 Sep 02:42 temp

drwxrwxrwx  1 501  20   1520  3 Sep 22:18 vendor content

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)


Code:
tell application "Finder"
    set _items to selection
    log "Items: " & (count of _items)

    set _first to first item of _items
    log "Disk: " & (disk of _first)
    log "Fold: " & (folder of _first)
    log "Name: " & (name of _first)
end tell


result
Code:
tell application "Finder"

    get selection

        --> {document file "tutorial.pdf" of folder "temp" of disk "home-1"}

    (*Items: 1*)

    get disk of document file "tutorial.pdf" of folder "temp" of disk "home-1"

        --> "home-1:"

    (*Disk: home-1:*)

    get folder of document file "tutorial.pdf" of folder "temp" of disk "home-1"

        --> "home-1:temp:"

    (*Fold: home-1:temp:*)

    get name of document file "tutorial.pdf" of folder "temp" of disk "home-1"

        --> "tutorial.pdf"

    (*Name: tutorial.pdf*)

end tell
[doublepost=1473278899][/doublepost]Ok, rebooted, remounted:

Code:
mount ; ls -na /Volumes/home* ; id

Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

//User1@DiskStation.local/home on /Volumes/home (afpfs, nodev, nosuid, mounted by user1)

total 72

drwxrwxrwx  1 501  20   1724  4 Sep 19:17 #recycle

drwx------@ 1 501  20    466  7 Sep 21:05 .

drwxrwxrwt@ 4 0    80    136  7 Sep 21:05 ..

-rwxrwxrwx@ 1 501  20  32772  7 Sep 21:05 .DS_Store

drwxrwxrwx@ 1 501  20    264 10 Jul 19:49 .TemporaryItems

drwxrwxrwx  1 501  20   1996  3 Sep 23:51 app content

drwxrwxrwx  1 501  20    264 22 Aug 14:45 collections

drwxrwxrwx  1 501  20    264  4 Sep 18:50 downloads

drwxrwxrwx  1 501  20   1350  6 Sep 23:20 my work

drwxrwxrwx  1 501  20    264  4 Sep 20:06 photo

drwxrwxrwx  1 501  20    704 14 Aug 19:45 repository

drwxrwxrwx  1 501  20   1044 21 Aug 13:56 sorted

drwxrwxrwx  1 501  20    398 28 Aug 21:04 sorting

drwxrwxrwx  1 501  20    772  7 Sep 02:42 temp

drwxrwxrwx  1 501  20   1520  3 Sep 22:18 vendor content

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)

result
Code:
error "Can’t make «class cdis» of «class docf» \"tutorial.pdf\" of «class cfol» \"temp\" of «class cdis» \"home\" of application \"Finder\" into type Unicode text." number -1700 from «class cdis» of «class docf» "tutorial.pdf" of «class cfol» "temp" of «class cdis» "home" to Unicode text
[doublepost=1473279118][/doublepost]So... another thing I have noticed...

I use VirtualBox to run a windows environment (I've not used it for a week or two). All the disk images for VirtualBox are stored on the NAS. When I open up VirtualBox now, I get an error saying it can't read the files and all disk images are "inaccessible", heres the error message

Code:
Runtime error opening '/Volumes/home/app content/VirtualBox/Virtual Disks/Windows 7 x64 (Clean Install)/Windows 7 x64 (Clean Install).vbox' for reading: -102(File not found.).

/Users/vbox/tinderbox/mac-rel/src/VBox/Main/src-server/MachineImpl.cpp[745] (nsresult Machine::i_registeredInit()).

Result Code:

NS_ERROR_FAILURE (0x80004005)

Component:

MachineWrap

Interface:

Machine {xxxx7866-a0a1-4391-8b86-6952d82efaa0}
[doublepost=1473279266][/doublepost]Very strange... just after typing the above message about VirtualBox, I clicked on the VirtualBox screen to add a new disk and then all of my "inaccessible" disks became available?! Closing / Opening no longer gives this error.
[doublepost=1473279929][/doublepost]Rebooted again, VirtualBox again now shows disk as "inaccessible"

Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

ls: /Volumes/home*: No such file or directory

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)

Appears home is not mounted. I have the "home" as a shortcut on my sidebar in Finder, clicking on that icon appears to force the share to mount. Im sure the connection used to always be established on user login.

result after clicking on "home"
Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

//User1@DiskStation.local/home on /Volumes/home (afpfs, nodev, nosuid, mounted by user1)

total 72

drwxrwxrwx  1 501  20   1724  4 Sep 19:17 #recycle

drwx------@ 1 501  20    466  7 Sep 21:23 .

drwxrwxrwt@ 4 0    80    136  7 Sep 21:23 ..

-rwxrwxrwx@ 1 501  20  32772  7 Sep 21:23 .DS_Store

drwxrwxrwx@ 1 501  20    264 10 Jul 19:49 .TemporaryItems

drwxrwxrwx  1 501  20   1996  3 Sep 23:51 app content

drwxrwxrwx  1 501  20    264 22 Aug 14:45 collections

drwxrwxrwx  1 501  20    264  4 Sep 18:50 downloads

drwxrwxrwx  1 501  20   1350  6 Sep 23:20 my work

drwxrwxrwx  1 501  20    264  4 Sep 20:06 photo

drwxrwxrwx  1 501  20    704 14 Aug 19:45 repository

drwxrwxrwx  1 501  20   1044 21 Aug 13:56 sorted

drwxrwxrwx  1 501  20    398 28 Aug 21:04 sorting

drwxrwxrwx  1 501  20    772  7 Sep 02:42 temp

drwxrwxrwx  1 501  20   1520  3 Sep 22:18 vendor content

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)
[doublepost=1473280393][/doublepost]Sorry for post overload!

I decided to try an alternate method.

As I'm sure your aware, the synology has a folder structure such as
homes\User1
homes\User2

When mounting to the mac, the User1 / User2 folder gets mounted as "home" for the OS.

So, I am logged into my Mac as User1, but disconnected from the NAS (Finder > "DiskStation" > "Connect As...") and this time logged in as "admin" on the DSM, and located the same file, this time by the homes\User1 folder. Run the script and it works this time.

Code:
tell application "Finder"

    get selection

        --> {document file "tutorial.pdf" of folder "temp" of folder "User1" of disk "homes"}

    (*Items: 1*)

    get disk of document file "tutorial.pdf" of folder "temp" of folder "'User1" of disk "homes"

        --> "homes:"

    (*Disk: homes:*)

    get folder of document file "tutorial.pdf" of folder "temp" of folder "User1" of disk "homes"

        --> "homes:User1:temp:"

    (*Fold: homes:User1:temp:*)

    get name of document file "tutorial.pdf" of folder "temp" of folder "User1" of disk "homes"

        --> "tutorial.pdf"

    (*Name: tutorial.pdf*)

end tell

just for good measure, this is the mount information, for the above run.
Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

//admin@DiskStation._smb._tcp.local/homes on /Volumes/homes (smbfs, nodev, nosuid, mounted by user1)

total 324

drwx------  1 501  20  16384  4 Sep 19:12 #recycle

drwx------@ 1 501  20  16384  7 Sep 13:27 .

drwxrwxrwt@ 4 0    80    136  7 Sep 21:26 ..

-rwx------@ 1 501  20  16388  7 Sep 21:26 .DS_Store

drwx------@ 1 501  20  16384  4 Sep 18:34 .TemporaryItems

-rwx------@ 1 501  20    291 22 Oct  2014 .apdisk

drwx------@ 1 501  20  16384  7 Sep 21:23 User1

drwx------  1 501  20  16384  4 Sep 22:06 User3

drwx------  1 501  20  16384 27 Jul 20:31 Time Machine Backup

drwx------@ 1 501  20  16384  7 Sep 13:36 admin

drwx------  1 501  20  16384 22 Oct  2014 guest

drwx------  1 501  20  16384  7 Sep 04:10 User2

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)

I notice it has swapped over to an SMB share for the above, not sure why this would be?
 
Last edited:
The inconsistency of the results is interesting, and not in a good way.

When the NAS share was mounted as "home-1", it worked fine, but then when it was mounted as "home" it failed. That doesn't make any sense to me. Then later, when you mounted a sharepoint as "homes", that also worked. Again, that makes no sense to me.

Something I hadn't thought of before: maybe the share name "home" is triggering a problem. This would be consistent with all observed results on your end, and on my end (I didn't use a share named "home", and everything works here).

The next thing for you to try is to change the name of the sharepoint so it's not "home". I suggest starting with something simple and predictable, like "example". If that works with 1 user and 1 share, try it with 2 users and 2 shares. If that all works, then try changing the name to something other than "example".

I can try a share name of "home" on my end, and see if it fails. I'll be away for a bit, so won't be able to get to it for a couple of hours.


I think El Capitan will look for an SMB service before looking for an AFP service. So if the server accepts the SMB connection and credentials, then you'll get SMB instead of AFP. I don't know what procedure you used to connect to "homes", but if you didn't specify AFP, then you'll probably get SMB.


Analyzing your output from the following:
Code:
mount ; ls -na /Volumes/home* ; id
When the mount info shows the mount on either "home-1" or "home", the info from the 'ls' command is consistent. In both cases, you own everything in the share (owned by 501, which is your userid), and permissions are read+write+search to all (permissions are rwxrwxrwx). This tells me it's not a permissions problem per se. There's a possibility the NAS is implementing AFP access wrong, but that seems unlikely, since all accesses work when the share isn't mounted as "home".

Earlier, I speculated that the problem might be confusion between "home-1" and "home", but I've now ruled that out. When I test things here with two mounts that have the same name, the OS automatically mounts one of them by appending a number, and all the scripts work fine when that happens. So the problem doesn't seem to be related to the "-1" suffixing, at least not here.
 
Ok, im not sure how to change the name of "home".

As stated previously, the "home" folder on the NAS is dynamic, so its content change based on who is logged in. Im sure you have a much better understanding of how this works than I do, but I feel reluctant to rename the "home" share on the NAS as the NAS is expecting this to be present and may make the NAS freak out is some manor.
[doublepost=1473284823][/doublepost]Ok... Out of curiosity I tried the same this time as SMB share.

So, I am logged in Mac as User1 and DiskStation as User1, and the script worked.

Code:
tell application "Finder"

    set _items to selection

    log "Items: " & (count of _items)

  

    set _first to first item of _items

    log "Disk: " & (disk of _first)

    log "Fold: " & (folder of _first)

    log "Name: " & (name of _first)

end tell

Code:
tell application "Finder"

    get selection

        --> {document file "tutorial.pdf" of folder "temp" of disk "home-1"}

    (*Items: 1*)

    get disk of document file "tutorial.pdf" of folder "temp" of disk "home-1"

        --> "home-1:"

    (*Disk: home-1:*)

    get folder of document file "tutorial.pdf" of folder "temp" of disk "home-1"

        --> "home-1:temp:"

    (*Fold: home-1:temp:*)

    get name of document file "tutorial.pdf" of folder "temp" of disk "home-1"

        --> "tutorial.pdf"

    (*Name: tutorial.pdf*)
end tell

heres the mount information
Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

//User1@DiskStation/home on /Volumes/home (smbfs, nodev, nosuid, mounted by user1)

//User1@DiskStation.local/home on /Volumes/home-1 (afpfs, nodev, nosuid, mounted by user1)

/Volumes/home:

total 482

drwx------  1 501  20  16384  4 Sep 19:17 #recycle

drwx------@ 1 501  20  16384  7 Sep 22:43 .

drwxrwxrwt@ 5 0    80    170  7 Sep 22:43 ..

-rwx------@ 1 501  20  32772  7 Sep 22:45 .DS_Store

drwx------@ 1 501  20  16384 10 Jul 19:49 .TemporaryItems

drwx------  1 501  20  16384  3 Sep 23:51 app content

drwx------  1 501  20  16384 22 Aug 14:45 collections

drwx------  1 501  20  16384  4 Sep 18:50 downloads

drwx------  1 501  20  16384  6 Sep 23:20 my work

drwx------  1 501  20  16384  4 Sep 20:06 photo

drwx------  1 501  20  16384 14 Aug 19:45 repository

drwx------  1 501  20  16384 21 Aug 13:56 sorted

drwx------  1 501  20  16384 28 Aug 21:04 sorting

drwx------  1 501  20  16384  7 Sep 02:42 temp

drwx------  1 501  20  16384  3 Sep 22:18 vendor content


/Volumes/home-1:

total 72

drwxrwxrwx  1 501  20   1724  4 Sep 19:17 #recycle

drwx------@ 1 501  20    466  7 Sep 22:43 .

drwxrwxrwt@ 5 0    80    170  7 Sep 22:43 ..

-rwxrwxrwx@ 1 501  20  32772  7 Sep 22:45 .DS_Store

drwxrwxrwx@ 1 501  20    264 10 Jul 19:49 .TemporaryItems

drwxrwxrwx  1 501  20   1996  3 Sep 23:51 app content

drwxrwxrwx  1 501  20    264 22 Aug 14:45 collections

drwxrwxrwx  1 501  20    264  4 Sep 18:50 downloads

drwxrwxrwx  1 501  20   1350  6 Sep 23:20 my work

drwxrwxrwx  1 501  20    264  4 Sep 20:06 photo

drwxrwxrwx  1 501  20    704 14 Aug 19:45 repository

drwxrwxrwx  1 501  20   1044 21 Aug 13:56 sorted

drwxrwxrwx  1 501  20    398 28 Aug 21:04 sorting

drwxrwxrwx  1 501  20    772  7 Sep 02:42 temp

drwxrwxrwx  1 501  20   1520  3 Sep 22:18 vendor content

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)
[doublepost=1473285704][/doublepost]Appears two volumes present above "home" and "home-1". Tried again by disconnecting all mounts and remounting as SMB share so just one volume. Logged in Mac as User1, DiskStation as User1.

Mount information:
Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

//User1@DiskStation._afpovertcp._tcp.local./Time%20Machine%20Backups on /Volumes/Time Machine Backups (afpfs, nobrowse)

/dev/disk2s2 on /Volumes/Time Machine Backups 1 (hfs, local, nodev, nosuid, journaled, nobrowse)

//User1@DiskStation/home on /Volumes/home (smbfs, nodev, nosuid, mounted by user1)

total 482

drwx------  1 501  20  16384  4 Sep 19:17 #recycle

drwx------@ 1 501  20  16384  7 Sep 22:43 .

drwxrwxrwt@ 6 0    80    204  7 Sep 22:57 ..

-rwx------@ 1 501  20  32772  7 Sep 22:56 .DS_Store

drwx------@ 1 501  20  16384 10 Jul 19:49 .TemporaryItems

drwx------  1 501  20  16384  3 Sep 23:51 app content

drwx------  1 501  20  16384 22 Aug 14:45 collections

drwx------  1 501  20  16384  4 Sep 18:50 downloads

drwx------  1 501  20  16384  6 Sep 23:20 my work

drwx------  1 501  20  16384  4 Sep 20:06 photo

drwx------  1 501  20  16384 14 Aug 19:45 repository

drwx------  1 501  20  16384 21 Aug 13:56 sorted

drwx------  1 501  20  16384 28 Aug 21:04 sorting

drwx------  1 501  20  16384  7 Sep 02:42 temp

drwx------  1 501  20  16384  3 Sep 22:18 vendor content

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)

run the same script again, which fails.
Code:
tell application "Finder"

    set _items to selection

    log "Items: " & (count of _items)

  

    set _first to first item of _items

    log "Disk: " & (disk of _first)

    log "Fold: " & (folder of _first)

    log "Name: " & (name of _first)

end tell

result
Code:
tell application "Finder"

    get selection

        --> {document file "tutorial.pdf" of folder "temp" of disk "home"}

    (*Items: 1*)

    get disk of document file "tutorial.pdf" of folder "temp" of disk "home"

        --> error number -1728 from folder "temp" of disk "home"

Result:

error "Can’t make «class cdis» of «class docf» \"tutorial.pdf\" of «class cfol» \"temp\" of «class cdis» \"home\" of application \"Finder\" into type Unicode text." number -1700 from «class cdis» of «class docf» "tutorial.pdf" of «class cfol» "temp" of «class cdis» "home" to Unicode text
 
Last edited:
Let's take a different approach.

First, unmount all the shares. If you run the 'mount' command there must be nothing on /Volumes/home.

Next, paste this into a Terminal window:
Code:
mkdir /Volumes/home
This creates an ordinary directory in the location where volumes are usually mounted. This should trick the automounter, which is responsible for managing dirs on which shares are mounted, into always using numbered dirs. That is, the automounter will see a dir already named "home", so the first mounted share will mount to /Volumes/home-1, the next one to /Volumes/home-2, and so on.

Now, try mounting one NAS share and run the scripts. The 'mount' command should show it mounted on /Volumes/home-1, rather than on /Volumes/home. Repeat with two mounted shares, etc.
 
Ok, makes sense.

unmounted shares
Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

ls: /Volumes/home*: No such file or directory

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)

run
Code:
mkdir /Volumes/home


Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

total 0

drwxr-xr-x+ 2 501  80   68  8 Sep 02:59 .

drwxrwxrwt@ 4 0    80  136  8 Sep 02:59 ..

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)

share mounted
Code:
/dev/disk0s2 on / (hfs, local, journaled)

devfs on /dev (devfs, local, nobrowse)

map -hosts on /net (autofs, nosuid, automounted, nobrowse)

map auto_home on /home (autofs, automounted, nobrowse)

//User1@DiskStation.local/home on /Volumes/home-1 (afpfs, nodev, nosuid, mounted by user1)

/Volumes/home:

total 0

drwxr-xr-x+ 2 501  80   68  8 Sep 02:59 .

drwxrwxrwt@ 5 0    80  170  8 Sep 03:02 ..


/Volumes/home-1:

total 72

drwxrwxrwx  1 501  20   1724  4 Sep 19:17 #recycle

drwx------@ 1 501  20    466  8 Sep 03:02 .

drwxrwxrwt@ 5 0    80    170  8 Sep 03:02 ..

-rwxrwxrwx@ 1 501  20  32772  8 Sep 00:15 .DS_Store

drwxrwxrwx@ 1 501  20    264 10 Jul 19:49 .TemporaryItems

drwxrwxrwx  1 501  20   1996  3 Sep 23:51 app content

drwxrwxrwx  1 501  20    264 22 Aug 14:45 collections

drwxrwxrwx  1 501  20    264  4 Sep 18:50 downloads

drwxrwxrwx  1 501  20   1384  8 Sep 00:07 my work

drwxrwxrwx  1 501  20    264  4 Sep 20:06 photo

drwxrwxrwx  1 501  20    704 14 Aug 19:45 repository

drwxrwxrwx  1 501  20   1044 21 Aug 13:56 sorted

drwxrwxrwx  1 501  20    398 28 Aug 21:04 sorting

drwxrwxrwx  1 501  20    772  7 Sep 02:42 temp

drwxrwxrwx  1 501  20   1520  3 Sep 22:18 vendor content

uid=501(user1) gid=20(staff) groups=20(staff),701(com.apple.sharepoint.group.1),12(everyone),61(localaccounts),703(com.apple.sharepoint.group.3),100(_lpoperator),704(com.apple.sharepoint.group.4),702(com.apple.sharepoint.group.2)


run
Code:
tell application "Finder"

    set _items to selection

    log "Items: " & (count of _items)

   

    set _first to first item of _items

    log "Disk: " & (disk of _first)

    log "Fold: " & (folder of _first)

    log "Name: " & (name of _first)

end tell


result
Code:
tell application "Finder"

    get selection

    (*Items: 1*)

    get disk of document file "tutorial.pdf" of folder "temp" of disk "home-1"

    (*Disk: home-1:*)

    get folder of document file "tutorial.pdf" of folder "temp" of disk "home-1"

    (*Fold: home-1:temp:*)

    get name of document file "tutorial.pdf" of folder "temp" of disk "home-1"

    (*Name: tutorial.pdf*)

end tell

 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.