ディレクトリ内の複数のファイルの名前を変更する方法

ディレクトリ内の複数のファイルの名前を変更する方法

次のファイルの名前を変更したい

Var1DecoderBase.cpp
Var1DecoderDerived.cpp
Var1EncoderBase.cpp
Var1EncoderDerived.cpp
Var1Factory.cpp

到着

Var4Config.cpp
Var4CountDownTimer.cpp
Var4DecoderBase.cpp
Var4DecoderDerived.cpp
Var4EncoderBase.cpp
Var4EncoderDerived.cpp
Var4Factory.cpp

rename次の方法で試しましたが、成功しませんでした。

rename Var1*.cpp Var4*.cpp ./src/
syntax error at (eval 1) line 1, near "*."

ベストアンサー1

Perlの名前変更を使用すると、次のことができます。

rename -n 's/Var1/Var4/' ./src/Var1*.cpp

を使用すると、-n実行する名前の変更のみが印刷されます。実際に名前を変更するにはそれなしで実行してください。

おすすめ記事