我正在使用以下内容来整理文件名。
for f in *; do mv "$f" "${f//remove/replace}"; done
我如何使用此解决方案或类似解决方案递归处理一堆子目录?
答案 0 :(得分:2)
有几种选择,这是我的最爱:
find <the-path> <the-criteria> | while read file; do mv $file <$file-renamed>; done
例如:
find . -name "*.jpg" | while read file; do mv "$file" "`echo $file | sed -e 's/jpg/png/'`"; done
使用sed
或构建替换名称所需的任何工具。