Asigning Paths, and Moving files... I clearly know nothing!

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

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

Hi,

try this

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

Dude… what a legend! :cool:

Totally works, and I even understand what you have written.

Just for future peoples reference…

You have a Folder hierachy of :

The Home Folder
[i]- A-folder

  • B-folder[/i]

… and within B-folder is a file (Image.psd)

When selecting ‘Image.psd’ and running the script, the file is moved up to The Home Folder, and then down into A-Folder.

(Or whatever you decide to call it. In this case ‘HR’)