views:

314

answers:

1

I'm writing a script to keep track of missing frames in a render (thousands of image files). to find the numbered frames in the sequence I do this:

set thecontents to every paragraph of (do shell script
"while IFS= read -r -d '' file;
do echo \"$file\"|sed -E \"s|.*[^[:digit:]]0*([[:digit:]]+)\\..*|\\1|\" ;
done< <(find \"" & thefolderPPath & "\" -name \"*.*\" -print0)")

find finds all the files, and sed strips everything but the trailing number off them - it matches the numbers when the file are numbered like foo_001.bar (or even if they're foo3_001.bar) it looks for a non digit, followed by a series of digits, followed by a dot extension, and chucks away everything but the digits.

It works in the shell, if I run it like this (without the escapes)

while IFS= read -r -d '' file
do echo "$file"|sed -E "s:.*[^[:digit:]]0*([[:digit:]]+)\..*:\1:" 
done < <(find "/Volumes/foo/imagesequence/" -name "*.*" -print0)

it produces a nice list of numbers, but in Applescript I get

"sh: -c: line 0: syntax error near unexpected token `<'

Any ideas? I can implement it with applescript by breaking the sed function and the find function into separate shell scripts, but that's way slower.

+1  A: 

It looks like you are using bash process substitution here:

<(find "/Volumes/foo/imagesequence/" -name "*.*" -print0)

The AppleScript do shell script command always uses /bin/sh (Posix shell semantics) and process substitution is not supported in Posix /bin/sh. Either rewrite the script to avoid Bash-isms or follow the suggestions here on how to run an AppleScript shell script with another shell.

Ned Deily
Well who'd a thunk it? Thanks.
stib