【发布时间】:2010-07-11 13:34:31
【问题描述】:
我需要在很多目录中转换大约12000个TIF文件,并尝试编写bash-script:
#!/bin/bash
find -name "*.tif" | while read f
do
convert "$f" "${f%.*}.png"
rm -f "$f"
done
为什么说:x.sh: 6: Syntax error: end of file unexpected (expecting "do") and what I should do?
非常感谢你们,伙计们,但我被骗了:应该运行它的计算机在 Windows 下工作。我不知道如何在 DOS 中处理字符串和循环,现在我的脚本如下所示:
FOR /R %i IN (*.tif) DO @ (set x=%i:tif%png) & (gm convert %i %xtif) & (erase /q /f %i)
%i - .tif 文件之一。
%x - 扩展名为 .png 的文件名
gm convert - 图形魔法实用程序,与图像魔法在 linux 上的转换类似。
【问题讨论】:
-
在你的脚本上试试 dos2unix。
-
我建议
convert "$f" "${f%.*}.png" && rm -f "$f"。否则,如果转换失败,您将失去重试的机会:)
标签: windows image batch-file cycle