Jump to content

Cannot execute osascript as written in AppleScript

Recommended Posts

Hi People, I'm super new to this thing so pardon me for basic newbie question,

i tried to make automation utilizing the mv commands with osascript in Alfred's script action
It works in AppleScript but not here. I've tried using the backslash, single quote, double quote (as seen in many cases here or in Stack Overflow) but it still not works for me.
It looks like this:


it gives me error like this:
ERROR: Move Item[Run Script] 396:443: execution error: sh: mv /Users/*****/Downloads/FileName.pdf /Users/******/Documents/*****/FileName.pdf: No such file or directory (127)

if i delete the single quote, it gives me error like this:

ERROR: Move Item[Run Script] 394:434: execution error: usage: mv [-f | -i | -n] [-v] source target

       mv [-f | -i | -n] [-v] source ... directory (64)

anyone have experience with this problem?
any help regarding this problem is really appreciated

Link to comment

do shell script "mv " & quoted form of SourcePath & " " & quoted form of DestinationPath & "/" & quoted form of Filename


In future, if you have a question regarding some code, post the code, not an image of it. Better yes, upload the whole workflow somewhere and post a link. If the error isn't obvious (as it is here), you're requiring us to re-create your script/workflow in order to be able to run it. That's not reasonable, and few people would even bother.


So help us to help you by making it as easy as possible for us to see the error for ourselves.

Link to comment

ah i see.. sorry for the trouble, i'll keep in mind in the future
I tried this too but it still won't fix it, and then i found the problem (i think if i upload the full work like you instruct it will be easier, my bad sorry)


It's about the file path: if there is a folder where there is space in it's name, the mv command won't work if i don't single quote the name.
For example:

Users/MyName/Dummy Folder/Sample File.png

It won't work unless i change it to

Users/MyName/'DummyFolder'/'Sample File'.png

and when we do File Filter action in Alfred, it gives path output without the single quote so.. it need something

so i google sample text handling and configure how to get this done

I'll post this workflow if anyone interested in this (might just build it from scratch tho except you're really new to this like me hahaha)


Thanks for your help deanishe 


Screen Shot 2020-06-26 at 12.21.53.png

Link to comment

No, what I wrote is kinda correct: you just need to use “quoted form of”, which will add the necessary quotes for you.


But I messed up the command above (which is what happens when you don’t have the workflow/code to actually test it).



do shell script "mv " & quoted form of SourcePath & " " & quoted form of (DestinationPath & "/" & Filename)



Edited by deanishe
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...