Jump to content
Sign in to follow this  
jhncbrwn

Take selected items and move them to a preset folder, Applescript question

Recommended Posts

I'm trying to write a workflow that takes the selected items in Alfred and moves them to a preset folder.

 

My applescript keeps giving me the error "Can’t get POSIX file"

 

Any suggestions would be appreciated.

set filelist to "{query}"
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to "\t"
set theArray to every text item of filelist
set AppleScript's text item delimiters to oldDelimiters

tell application "Finder"
	repeat with eachitem in theArray
		set a to POSIX file eachitem
		set b to POSIX file "Macintosh HD/Users/USERNAME/Desktop/Temp" as text
		move a to b
	end repeat
end tell

Share this post


Link to post

 

I'm trying to write a workflow that takes the selected items in Alfred and moves them to a preset folder.

 

My applescript keeps giving me the error "Can’t get POSIX file"

 

Any suggestions would be appreciated.

set filelist to "{query}"
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to "\t"
set theArray to every text item of filelist
set AppleScript's text item delimiters to oldDelimiters

tell application "Finder"
	repeat with eachitem in theArray
		set a to POSIX file eachitem
		set b to POSIX file "Macintosh HD/Users/USERNAME/Desktop/Temp" as text
		move a to b
	end repeat
end tell

 

Try this code:

set filelist to “{query}"
set text item delimiters to tab
set theArray to every text item of filelist
set text item delimiters to ""
repeat with eachitem in theArray
	set a to POSIX file (eachitem)
	set b to POSIX file ("/Users/USERNAME/Desktop/Temp")
	tell application "Finder" to move a to b
end repeat

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  
×
×
  • Create New...