2013-11-27 78 views
2

我使用以下命令来整理文件名。在子目录中重命名文件名

for f in *; do mv "$f" "${f//remove/replace}"; done 

我怎样才能使用这个或类似的解决方案递归地工作通过一堆子目录?

回答

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或任何工具,你需要建立的替代名称。