0
我需要使用名爲process.bat
的蝙蝠來處理某些子目錄中的所有jpg文件。
Windows蝙蝠:如何循環子目錄中的文件
dir
|---subdir1
| |-----a.jpg
| |-----b.jpg
|
|---subdir2
|-----c.jpg
|-----d.jpg
process.bat dir/subdir1/a.jpg dir/subdir1/b.jpg
process.bat dir/subdir2/c.jpg dir/subdir2/d.jpg
在Linux中,我能做出這樣的腳本:
find $1 -type d | while read dir; do
files=("$dir"/*.jpg)
if [ ${#files[@]} -gt 0 ]; then
if ! [[ $files =~ \* ]]; then
process.bat "${files[@]}"
fi
fi
done
但我不知道該怎麼做同樣的事情在Windows中。
我知道環路如何將文件在Windows蝙蝠:for /r %%i in (*) do echo %%i
https://stackoverflow.com/questions/44402963/windows-bat-loop-files-in-d irectories – Yves
在此鏈接閱讀我的答案。重新編輯一下你的答案可能對其他人更有幫助。 – Yves