LoginSignup
4
5

More than 5 years have passed since last update.

メモ : Mac でファイル(の拡張子)を再帰的に一括変換する

Last updated at Posted at 2015-11-26

カレントフォルダ以下のファイル(及び、その拡張子)を一括変換したい人向けのメモ

1) brewでrenameを入れる。

Linuxのrenameとは別物らしいが、brewでrenameが入るとのこと。

$ brew install rename
$ rename -h
Usage:
    rename [switches|transforms] [files]

    Switches:
(いろいろあるが略)
    -s/--subst *from* *to*
    -S/--subst-all *from* *to*
    -x/--remove-extension
    -X/--keep-extension
    -z/--sanitize
    --camelcase --urlesc --nows --rews --noctrl --nometa --trim (see manual)

要するにAliceをBobに置換する場合、

rename -s Alice Bob

とする。

2) カレントフォルダ以下のファイルを一括変換

例、カレントフォルダ以下のファイルの拡張子.ktを.kt_に一括リネームしたい場合:

① カレントフォルダ以下のファイルを一覧。

find . -name *.kt

② 問題なければ、一括rename。

find . -name *.kt | xargs rename -s .kt .kt_

おしまい。

誰得?

例、クロスプラットフォーム開発で共通モジュールを移植する時など、特定フォルダ以下のコードをコンパイラに当座触ってほしくないファイルがた〜くさんある人など(...ただいま、KotlinでAndroid/iOSクロスプラットフォーム開発にトライアル中...)

...すみません、事実上、こちらの記事のパクリですね。。
http://qiita.com/shuhei/items/cf1ddf373d1f83d5d667

4
5
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
4
5