Hi Folks-
I’ve having trouble with spaces in filenames- I’ve read up on ‘quoted form of POSIX’ but still getting errors.
do shell script "find -X '/JobsX/#150,000-150,999/150001_PlanSponsor AD/FinalFile' \\( -name '150001_fnl.pdf' -o -name '150001_seps.pdf' -o -name '150001_callout*.pdf' \\) -print0 | xargs -0 -J {} cp {} ''/WamX/150001"
the space between ‘PlanSponsor’ and AD generates the error.
i compile the first path via a ‘quoted form of POSIX’, but this doesn’t matter.
any ideas? thanks!
Ralph
StefanK
October 14, 2008, 1:45pm
#2
Hi Ralph,
have you tried to escape the space(s) instead of using single quotes
do shell script "find -X /JobsX/#150,000-150,999/150001_PlanSponsor\\ AD/FinalFile \\( -name '150001_fnl.pdf' -o -name '150001_seps.pdf' -o -name '150001_callout*.pdf' \\) -print0 | xargs -0 -J {} cp {} ''/WamX/150001"
escaping the space with one \ or two \ does not work.
-RL
Hi Jaques-
in a cursory test, removing -X worked, but per the man page:
-X The -X option is a modification to permit find to be safely used
in conjunction with xargs(1). If a file name contains any of the
delimiting characters used by xargs(1), a diagnostic message is
displayed on standard error, and the file is skipped. The delim-
iting characters include single ( ' '') and double (
" ‘’)
quotes, backslash (``''), space, tab and newline characters.
since i’m using xargs i’m wondering what is happening here…
-Ralph
I changed the script to see how the final string is compiling before it is executed
set theShell to "find -X '/JobsX/#150,000-150,999/150001_PlanSponsor AD/FinalFile' \\( -name '150001_fnl.pdf' -o -name '150001_seps.pdf' -o -name '150001_callout*.pdf' \\) -print0 | xargs -0 -J {} cp {} ''/WamX/150001"
And ran it. The final shell script is:
find -X ‘/JobsX/#150 ,000-150,999/150001_PlanSponsor AD/FinalFile’ \( -name ‘150001_fnl.pdf’ -o -name ‘150001_seps.pdf’ -o -name ‘150001_callout*.pdf’ \) -print0 | xargs -0 -J {} cp {} ‘’/WamX/150001
Does that look correct? I am not an expert in shell scripts but maybe someone else out there is. What do the double-backslashes do? Is that right?
thanks for the help Jaques- I never thought to question the manual.
Matt-boy- the \ is for escaping the space following it. From what I’ve read usually only one \ is required, but for some reason two \ seems to do the trick when calling a line command from AS. If anyone has an explanation for why two are needed, I’m curious!
-ralph
Interesting! I haven’t seen that before.
Yeah, does anyone know what that is all about?
StefanK
October 23, 2008, 2:00pm
#8
in AppleScript the backslash is a special character to escape characters like tab (\t), return (\r), linefeed (\n) and the backslash itself (\).
In a shell command line space characters are parameter separators. Space characters in parameters like a path must be wrapped in quotes e.g.
myComputer: ~ myuser$ /bin/ls '/Library/Application Support'
or escaped with a backslash
myComputer: ~ myuser$ /bin/ls /Library/Application\ Support
the AppleScript syntax of the second line is
do shell script "/bin/ls /Library/Application\\ Support"