Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
709 views
in Technique[技术] by (71.8m points)

macos - How can I batch rename files using the Terminal?

I have a set of files, all of them nnn.MP4.mov. How could I rename them so that it is just nnn.mov?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First, do a dry run (will not actually rename any files) with the following:

for file in *.mov
do
  echo mv "$file" "${file/MP4./}"
done

If it all looks fine, remove the echo from the third line to actually rename the files.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...