Linux - Replacing spaces in the file names

前端 未结 11 663
臣服心动
臣服心动 2021-01-29 18:21

I have a number of files in a folder, and I want to replace every space character in all file names with underscores. How can I achieve this?

11条回答
  •  梦毁少年i
    2021-01-29 18:46

    Quote your variables:

    for file in *; do echo mv "'$file'" "${file// /_}"; done
    

    Remove the "echo" to do the actual rename.

提交回复
热议问题