Hey Peter,
Firstly let me put my moderator hat on and ask that you use proper technique when posting code or any text that must be protected from being rendered by HTML.
How to Post Code (Scripts) on the KM Forum; and Macro to Paste AppleScript in a Code Block
It limits the possibility of mangled code/data and saves everyone time and aggravation.
Also β when posting code please try to post a test case that's complete enough to run on the tester's machine.
To test your code above we have to make assumptions.
Now β to your problem...
Never piece together shell code in AppleScript and execute it on the same line. Use a construct like this:
# This works out of the box.
set temp_folder to "~/'test_directory/mv_source'/"
set destination_folder_pg to "~/'test_directory/mv_destination'/"
set thetitle to "Peter Test File.txt"
set shCmdStr to "mv " & temp_folder & "* " & destination_folder_pg & quoted form of thetitle
do shell script shCmdStr
This way you can comment-out the do shell script line, run the script, and eyeball the shell code prior to execution.
Note where I've single-quoted my paths above. This is not necessary with this script, because there are no spaces in those paths, BUT it's a good habit to get into β because spaces WILL bite you sooner or later.
In fact I think they did bite you in your script above. I think it's balking because you probably have spaces in your file name.
Next question: Why are you using the shell to move your file when you're already in AppleScript?
--------------------------------------------------------
# Auth: Christopher Stone <scriptmeister@thestoneforge.com>
# dCre: 2021/06/03 06:23
# dMod: 2021/06/03 06:23
# Appl: Finder
# Task: Move a File from a Target Dir to a Destination Dir.
# : Rename the file if necessary.
# Libs: None
# Osax: None
# Tags: @cctone, @Applescript, @Script, @ASObjC, @Finder, @Move, @File, @Rename.
--------------------------------------------------------
use AppleScript version "2.4" --Β» Yosemite or later
use framework "Foundation"
use scripting additions
set tempFolderPath to "~/test_directory/mv_source/"
set destinationFolderPath to "~/test_directory/mv_destination/"
set fileName to "Peter Test File.txt"
set tempFolderPath to alias POSIX file (((current application's NSString's stringWithString:tempFolderPath)'s stringByExpandingTildeInPath) as text)
set destinationFolderPath to alias POSIX file (((current application's NSString's stringWithString:destinationFolderPath)'s stringByExpandingTildeInPath) as text)
tell application "Finder"
set fileToMoveRef to first item of tempFolderPath as alias
set movedFileRef to move fileToMoveRef to destinationFolderPath
if name of movedFileRef is not fileName then set name of movedFileRef to fileName
end tell
--------------------------------------------------------
Next question: Do you need to be in AppleScript at all? Can you just use a Execute a Shell Script action and keep everything in the shell?
Or β can you use Keyboard Maestro's own Move or Rename a File action?
-Chris