How to batch rename files using bash
Posted
by
Alex Popov
on Super User
See other posts from Super User
or by Alex Popov
Published on 2013-11-05T08:38:30Z
Indexed on
2013/11/05
9:58 UTC
Read the original article
Hit count: 479
I know there are lots of such questions, but I couldn't find one (or a combination of several), which describes the things I want to do. I think I need to use regular expressions, but I am not very good with that. I use zsh. I have a folder with files, which I want to rename:
I want the files
challenge1.rb
,challenge2.rb
,challenge3.rb
, etc. to be renamed toc1.rb
,c2.rb
etc. Similarlytask1.rb
and similar must be renamed tot1.rb
etc.sample_spec_c1.rb
,sample_spec_c2.rb
etc. must be renamed toc1_spec.rb
,c2_spec.rb
etc.
So I guess I need some combination of regular expressions and iteration, but I don't know how to write the bash script.
© Super User or respective owner