更新时间:2023-01-18 15:31:49
为 for
循环提供的文件名列表实际上包含 find
.我认为您要执行的操作是提供 find
的 output ,搜索当前目录中或该目录下的所有PNG图片.
The list of filenames you are giving to the for
loop literally contains find
. I think what you meant to do is give the output of find
, searching for all PNG images in or under the current directory, which is
for f in $(find . -iname '*.png'); do convert "$f" "$f".pdf; done
这将不能很好地处理空格.更好的解决方案是只在 find
本身内部运行转换,
This will not handle spaces well. A better solution is to just run the conversion from within find
itself,
find "$PWD" -iname '*.png' -execdir convert '{}' '{}'.pdf \;
尽管请注意,最后将使用以 .png.pdf
Although note that you will wind up with filenames ending with .png.pdf