Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

rename help

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
newbie2008
Posts: 4
Joined: 2018-05-31 22:40

rename help

#1 Post by newbie2008 »

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?

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

Re: rename help

#2 Post by Justin417 »

Hello!

Try:

Code: Select all

rename -v 's/[^_]*_[^_]*_/wallpaper_/g' *jpg
That should work.

Bulkley
Posts: 6383
Joined: 2006-02-11 18:35
Has thanked: 2 times
Been thanked: 39 times

Re: rename help

#3 Post by Bulkley »

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.

newbie2008
Posts: 4
Joined: 2018-05-31 22:40

Re: rename help

#4 Post by newbie2008 »

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?

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: rename help

#5 Post by debiman »

iirc, rename uses "sed-like syntax" - so search for sed solutions.

Post Reply