I'm using AppleScript to rename a file and move it to a folder. This is executed using a voice command. It doesn't move the file to the folder, it presses Enter, renames the file to "myFile", presses Enter again.
However, if I execute this a second time, or if the file is named "myFile", It will work. I think the code that moves the file doesn't know, or is not updated on the file name. I don't know how to fix this. AppleScript is not my thing.
tell application "System Events"
key code 36
keystroke "myFile"
key code 36
end tell
tell application "Finder"
move POSIX file "/Users/joe/Desktop/myFile.csv" to POSIX file "/Users/joe/Desktop/TestFolder" with replacing
end tell