rename help

If none of the more specific forums is the right place to ask

rename help

Postby newbie2008 » 2018-05-31 22:47

What I have:
pic_2001-01-01_001.jpg
pic_2002-02-02_002.jpg
pic_2003-03-03_003.jpg

What I want:
wallpaper_01.jpg
wallpaper_02.jpg
wallpaper_03.jpg

What I used:
rename 's/*_0/wallpaper_/g' *jpg

What I got:
Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE _0/ at (eval 1) line 1.

What is the correct CLI?
newbie2008
 
Posts: 4
Joined: 2018-05-31 22:40

Re: rename help

Postby Justin417 » 2018-05-31 23:09

Hello!

Try:
Code: Select all
rename -v 's/[^_]*_[^_]*_/wallpaper_/g' *jpg


That should work.
User avatar
Justin417
 
Posts: 29
Joined: 2014-06-01 02:26
Location: Pittsburgh, PA

Re: rename help

Postby Bulkley » 2018-05-31 23:11

Code: Select all
mv pic_2001-01-01_001.jpg wallpaper_01.jpg



As to "correct" this is Linux and there are always several ways to do anything.
Bulkley
 
Posts: 5598
Joined: 2006-02-11 18:35

Re: rename help

Postby newbie2008 » 2018-06-16 15:35

Thanks, Justin.

And what would the opposite code look like?

Say, how can this:

01_pic_2001-01-01.jpg
02_pic_2002-02-02.jpg
03_pic_2003-03-03.jpg

Become this?:

01_wallpaper.jpg
02_wallpaper.jpg
03_wallpaper.jpg

'man rename' is very short. Is there a longer version of it?
newbie2008
 
Posts: 4
Joined: 2018-05-31 22:40

Re: rename help

Postby debiman » 2018-06-17 07:14

iirc, rename uses "sed-like syntax" - so search for sed solutions.
User avatar
debiman
 
Posts: 2586
Joined: 2013-03-12 07:18


Return to General Questions

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable