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.
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: