Help us understand the problem. What is going on with this article?

ファイルの拡張子を一括で変更する

More than 3 years have passed since last update.

もともと

ls
1.csv.gz    2.csv.gz    3.csv.gz    4.csv.gz    5.csv.gz

ターミナル(mac)

for filename in *.csv.gz; do
> mv $filename ${filename%.csv.gz}.csv;
> done

ワンライナーでもok

for filename in *.rb; do mv $filename ${filename%.rb}.txt; done
for filename in *.!!変更前の拡張子!!; do
> mv $filename ${filename%.!!変更前の拡張子!!}.!!変更後の拡張子!!;
> done

変更後

ls
1.csv   1.csv   1.csv   4.csv   5.csv
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away