Linux - Replacing spaces in the file names

前端 未结 11 755
臣服心动
臣服心动 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条回答
  •  难免孤独
    2021-01-29 19:05

    Try something like this, assuming all of your files were .txt's:

    for files in *.txt; do mv “$files” `echo $files | tr ‘ ‘ ‘_’`; done
    

提交回复
热议问题