I’m trying to :
¢ Get the user selected file
¢ Get the path to said file
¢ Go up a Level relative to the path
¢ Go to a different folder at the new level (in this case, named ‘HR’)
¢ Move the originally Selected file to the new location (the HR folder)
Clearly I’m failing but I can’t work out why
I’ve got all the books, all the guides, but… well… what do you think…
tell application "Finder"
set theOriginalSel to selection as alias
set thePathtoOriginalSel to POSIX path of theOriginalSel
set theSelText to POSIX path of (parent of first item of (get selection as alias list) as alias)
set theNameHR to "HR"
set theFullPath to theSelText & theNameHR
move thePathtoOriginalSel to theFullPath with replacing
end tell
tell application "Finder"
set theSelection to selection
if theSelection is not {} then
set fileToMove to item 1 of theSelection
set parentFolder to container of container of fileToMove
set theNameHR to "HR"
move fileToMove to folder theNameHR of parentFolder with replacing
end if
end tell
or affecting all selected files
tell application "Finder"
set theSelection to selection
if theSelection is not {} then
set fileToMove to item 1 of theSelection
set theNameHR to "HR"
set parentFolder to container of container of fileToMove
repeat with anItem in theSelection
move anItem to folder theNameHR of parentFolder with replacing
end repeat
end if
end tell