如何使用 git-bash 为 windows 10 目录中的文件添加扩展名

How to add extensions to files in windows 10 directory with git-bash

我正在使用 git-bash 在 win 10 中工作。我上面列出了一些没有扩展名的文件。我想为所有文件添加 .jpg 扩展名。我试过了

$ for f in *; do mv "$f" "${f%.jpg}"; done

我做错了什么?

你想要这个:

$ for f in *; do mv "$f" "$f.jpg"; done

您的解决方案更倾向于删除扩展而不是添加它们。

你不需要 %

$ for f in *; do mv "$f" "${f}.jpg"; done