我试图使用下面的命令来查找当前目录中的所有PDF(不是递归的),但是我认为它不喜欢-out上的“{}”。
find . -iname "*.pdf" -maxdepth 1 -exec sips -s format jpeg --resampleHeightWidth 129 100 '{}' --out '{}'.jpg \;与-print和sips一起使用时,查找工作在我指定名称-out test.jpg时起作用。有什么办法让这件事成功吗?还是我应该试试沙格?我不想为了简单而使用循环..。有什么想法吗?
更新:我尝试使用xargs -但是再次得到一个错误out_dir_not_found。
find . -iname "*.pdf" -maxdepth 1 -print0 | xargs -0 -I % sips -s format jpeg --resampleHeightWidth 129 100 % --out "%.jpg"
mymbpro:pdfs dh$ find . -iname "*.pdf" -maxdepth 1 -print0 | xargs -0 -I % sips -s format jpeg --resampleHeightWidth 129 100 % --out "%.jpg"
Error 10: out_dir_not_found /Users/darenhunter/Desktop/pdfs/ATTENTION.pdf.jpg
Try 'sips --help' for help using this tool
Error 10: out_dir_not_found /Users/darenhunter/Desktop/pdfs/DisNCLB119.pdf.jpg
Try 'sips --help' for help using this tool
Error 10: out_dir_not_found /Users/darenhunter/Desktop/pdfs/services2012.pdf.jpg
Try 'sips --help' for help using this tool
Error 10: out_dir_not_found /Users/darenhunter/Desktop/pdfs/Fall2011.pdf.jpg
Try 'sips --help' for help using this tool发布于 2013-01-29 18:40:22
如果要对许多结果执行,则更有效的方法是将结果输送到
xargs命令。xargs是一种更现代的实现,它以更智能的方式处理长列表。print0选项可以与此一起使用。 下面的命令将确保带空格的文件名传递给已执行的命令,而不会被shell拆分。乍一看,它看起来很复杂,但却得到了广泛的应用。
find . -print0 | xargs -0 COMMANDref
https://stackoverflow.com/questions/14589053
复制相似问题