Can you coerce a result into a shell script?

Hello all,

We have a copier/scanner that sends pdfs to a Windows machine. I wrote a script that mounts the windows shared folder that contains the pdfs, finds the most recent one, renames it and copies it to a web folder (another mounted sharepoint).

Unfortunately this script only works 1 or 2 times out of 5! I will post the script in another topic, but I started thinking that I would blow off most of the script and use a “do shell script” command to get the file where I need to.

Here’s the details. I use this to find out what the most recent PDF file is:

tell application "Finder"
	set item_list to (every item of disk "INCOMING_SCANS")
	set item_list to (sort item_list by modification date)
	set newest_item to item 1 of item_list
end tell

Now “newest_item” is a file name. Can I coerce this file name into something I can use in a shell script?

For instance:

do shell script "ditto -rsrc /Volumes/INCOMING_SCANS/(newest_item would go here) /Volumes/web-folder/news/current_news.pdf"

I am clueless how to get the result from “newest_item” into the shell script. Any ideas?

Thank you,


Hi Dave,

coercing the file specifier to an alias and then to a POSIX path you can use it (with the whole path) like this

do shell script "ditto -rsrc " & quoted form of POSIX path of (newest_item as alias) & " /Volumes/web-folder/news/current_news.pdf"

Note: the quoted form is needed if there are spaces in the path