Having to write and maintain an osascript command as you have is really not the best way to go in this use case IMO.
Using a Run AppleScript action, instead of a Run Shell Script action, the following example AppleScript code will resolve the issue you are currently having, and makes the code much easier to read and edit:
on run {input, parameters}
set cbInfoAsString to (clipboard info) as string
if cbInfoAsString does not contain "«class furl»" and ¬
cbInfoAsString contains "TIFF picture" then
set formattedDate to do shell script ¬
"date -j '+%Y-%m-%d at %I.%M.%S %p'"
tell application "Finder" to set thePath to ¬
(insertion location as alias) & ¬
formattedDate & ".png" as string
do shell script "/usr/local/bin/pngpaste " & ¬
the quoted form of the POSIX path of thePath
else if cbInfoAsString contains "«class furl»" then
tell application "System Events" to ¬
keystroke "v" using control down
end if
end run
Notes:
POSIX path is a part of Standard Additions not Finder, and should not be wrapped within a tell statement of Finder.
- If not setting the date with the
date command, use the -j option.
- I modified your
date command to use 12-Hour Time as typically 24-Hour Time does not use AM/PM and have added made additional modifications to make it more readable, and in line with the system default used with screen shots.
- If you want 24-Hour Time then use e.g.:
"date -j '+%Y-%m-%d at %H.%M.%S'"
- As coded, if there is anything other than a file(s)/folder(s) or just an image, the script will not attempt to process text if that's what's on the clipboard.