Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个充满图片的目录。让我们说
/usr/pics/foo /usr/pics/duckface.jpg usr/pics/bar.bmp ...
我想通过并将它们重命名为
/usr/pics/pic1 /usr/pics/pic2 /usr/pics/pic3 ...
不必是sed我可以从bash脚本运行的任何东西都可以。我想我可以处理我只是不知道用什么替换的正则表达式。
sed
bash
我假设目录中的所有文件都是图像,并且您想重命名所有文件而不用担心扩展名或文件类型。然后尝试:
for f in /usr/pics/*; do ((i++)); mv "$f" "${f%/*}/pic${i}"; done