ある拡張子から別の拡張子にファイル名を一括変更しようとしています(背景:私のRailsアプリでerbの代わりにhamlを使用しています)。名前変更コマンドを実行すると、次の出力が表示されます。
% zmv '**/*.erb' $1.haml
zmv: error(s) in substitution:
app/views/l/links/index.html.erb and app/views/index/index.html.erb both map to .haml
app/views/l/links/new.html.erb and app/views/l/links/index.html.erb both map to .haml
app/views/l/links/show.html.erb and app/views/l/links/new.html.erb both map to .haml
app/views/l/links/stats.html.erb and app/views/l/links/show.html.erb both map to .haml
app/views/layouts/application.html.erb and app/views/l/links/stats.html.erb both map to .haml
app/views/u/profiles/_form.erb and app/views/layouts/application.html.erb both map to .haml
app/views/u/profiles/edit.html.erb and app/views/u/profiles/_form.erb both map to .haml
app/views/u/profiles/show.html.erb and app/views/u/profiles/edit.html.erb both map to .haml
app/views/u/user_sessions/new.html.erb and app/views/u/profiles/show.html.erb both map to .haml
app/views/u/users/_form.erb and app/views/u/user_sessions/new.html.erb both map to .haml
app/views/u/users/new.html.erb and app/views/u/users/_form.erb both map to .haml
app/views/u/users/show.html.erb and app/views/u/users/new.html.erb both map to .haml
誰もがこの問題を解決するために正しい方向を教えてもらえますか?
ベストアンサー1
私はあなたが本当に欲しいものは次のとおりだと思います。
% zmv '(**/)(*).erb' '$1/$2.haml'
# ^$1 ^$2
括弧を使用して一致グループを作成し、ファイルパスの一致グループを作成し、ファイル名の一致グループを作成する必要があります。また、zmvの2番目の引数も単一引用符で囲む必要があります。
また、実行する前に「-n」を使用してzmvコマンドをテストすることは非常に良い考えです。 (-nは名前が変更されることを示しますが、実際には名前は変更されません。)