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
904 views
in Technique[技术] by (71.8m points)

macos - Regex to batch rename files in OS X Terminal

I'm after a way to batch rename files with a regex i.e.

s/123/onetwothree/g

I recall i can use awk and sed with a regex but couldnt figure out how to pipe them together for the desired output.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

You can install perl based rename utility:

brew install rename

and than just use it like:

rename 's/123/onetwothree/g' *

if you'd like to test your regex without renaming any files just add -n switch


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

...