2009-11-04 160 views
1

我正在编写一个脚本来跟踪渲染(成千上万的图像文件)中丢失的帧。找到序列中的编号帧我这样做: - 当文件编号喜欢foo_001.bar(它的数量相匹配applescript + shell脚本问题

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)") 

发现找到的所有文件,和sed去掉一切,但尾随数了他们或者即使它们是foo3_001.bar),它会查找非数字,然后是一系列数字,后跟一个点扩展名,然后删除除数字之外的所有数字。

它工作在shell,如果我运行像这样(不逃逸)

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

它产生数字的一个不错的名单,但在AppleScript的,我得到

“SH: -c:行0:近 意外的标记'<'

任何想法语法错误,我可以打破的sed使用AppleScript实现它函数和查找功能放入单独的shell脚本中,但速度较慢。

回答

2

看起来你正在使用bash进程替换的位置:

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

的AppleScript的do shell script命令始终使用/bin/shPosix外壳语义)和进程替换不Posix /bin/sh支持。重写脚本以避免Bash -isms或遵循建议here关于如何使用另一个shell运行AppleScript shell脚本。

+0

那么会是谁呢?谢谢。 – stib 2009-11-04 06:52:49