LoginSignup
13
10

More than 5 years have passed since last update.

ターミナルでファイル名に含まれるスペースをアンダーバーにまとめて置換

Posted at

findコマンドとrenameコマンドを使って、現在のディレクトリから下の階層にあるファイルやディレクトリで、ファイル名やディレクトリ名に含まれるスペースをアンダーバーにまとめて置換する方法。

find . -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;

renameコマンドはデフォルトでMacには入ってないのでHomebrewでインストールする。

brew install rename

参考

http://stackoverflow.com/questions/2709458/bash-script-to-replace-spaces-in-file-names
http://qiita.com/shuhei/items/cf1ddf373d1f83d5d667

13
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
10