开发者

applescript + shell script problem

开发者 https://www.devze.com 2022-12-10 16:16 出处:网络
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:

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 th开发者_Python百科is (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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消