The speed of entire contents is dependent on the size of the volume and number of files in the target folder. If the folder is relatively small, it’s quick enough. The entire contents of the desktop in my case returned in a fraction of a second and I have a reasonable amount of stuff (6 folders and 5 files) on the desktop. Never even try it with a whole volume of any size! (trust me)
So yeah, if you are dealing with large folders, go with the shell.
set wrttest to every file of entire contents of (desktop folder)
it timed out… eventually. then I force-quit the finder.
since I haven’t figured out how to do the shell script “find” with two areas (beginning and end) I’m using the ‘entire contents’ for now…
tell application "Finder"
set wrttest to every file of entire contents of (vjobpath as alias) whose name starts with vdigits and name ends with "wrt.pdf"
set wrttest to (first item of wrttest as alias)
set wrtloc to quoted form of POSIX path of wrttest
end tell
I’ve set the following variable for destination:
set emloc to POSIX path of "Users:SHARED:_ PDF Final Files (low res):Electronic Marketing:" & eps & ".pdf"
--or alternately
set emloc to "/Users/SHARED/_ PDF Final Files (low res)/Electronic Marketing/" & eps & ".pdf"
but when I run:
do shell script "mv " & wrtloc & " " & emloc
I get the following error:
do shell script "mv '/Users/a351958/Desktop/automation testing/999997_wrt.pdf' /Volumes/Users/SHARED/_ PDF Final Files (low res)/Electronic Marketing/1.999999.pdf"
"sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: `mv '/Users/a351958/Desktop/automation testing/999997_wrt.pdf' /Volumes/Users/SHARED/_ PDF Final Files (low res)/Electronic Marketing/1.999999.pdf'"
Yep. The shell doesn’t approve of spaces in path names. You need to either put the path in quotes or escape the space character with a "" character like this:
/Volumes/Users/SHARED/_ PDF Final Files (low res)/Electronic[b][/b] Marketing/1.999999.pdf
You have spaces and “(” in your path name which unix will confuse as part of the command or options for the command.
To get around this you can either escape the space and characters like “(” .
Escaping makes unix look at the character as a literal character, part of the string rather than part of the command.
In an Applescript Do Shell command use \ just before the character you want to escape on a posix path formated string.
the first \ is actually to escape the second \ for applescripts own purposes.
In unix you only need 1 .
But because in the example below I have used set destinationPath to POSIX path of “Users:SHARED:_ PDF Final Files (low res):Electronic Marketing:” Mac path format.
Its easier for me to try a second method, enclosing the string in single quotes. This has a similar effect of making all the characters literal. Note : the quoted form of below
There is a lot more to it than what I could put here, and much more accurate than what I have put here.
Search out unix and escaping.
set yourfilePath to "/Users/UserName/Desktop/_Lemke_Software_GmbH_-_order_with_Element_5_.pdf"
set destinationPath to POSIX path of "Users:SHARED:_ PDF Final Files (low res):Electronic Marketing:"
do shell script "mv " & quoted form of yourfilePath & " " & quoted form of destinationPath
do shell script "mv " & quoted form of wrtloc & " " & quoted form of emloc
Try something like this:
-- I'm not sure what kind of value you're using for `vjobpath`
set vjobpath to text 1 thru -2 of POSIX path of (path to documents folder)
set vdigits to "6152"
do shell script "/usr/bin/find " & quoted form of vjobpath & " -type f -iname " & quoted form of (vdigits & "*wrt.pdf")
set test to paragraphs of result