LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-18-2012, 04:08 PM   #1
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 346

Rep: Reputation: 38
Simple SED with rename


just curious as to why this command fails to rename my files:

Code:
$ rename -v "s/HDTV.*/mkv/g" *.mkv
$ ls
Archer.S01E01.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E02.720p.HDTV.X264-LiLDiCK.mkv
Archer.S01E03.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E04.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E05.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E06.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E07.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E08.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E09.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E10.720p.HDTV.x264-immerse.mkv
idx.txt
I tested the sed expression and that works fine.

Code:
$ cat idx.txt && cat idx.txt | sed "s/HDTV.*/mkv/g"
Archer.S01E01.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E02.720p.HDTV.X264-LiLDiCK.mkv
Archer.S01E03.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E04.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E05.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E06.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E07.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E08.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E09.720p.HDTV.X264-DIMENSION.mkv
Archer.S01E10.720p.HDTV.x264-immerse.mkv

Archer.S01E01.720p.mkv
Archer.S01E02.720p.mkv
Archer.S01E03.720p.mkv
Archer.S01E04.720p.mkv
Archer.S01E05.720p.mkv
Archer.S01E06.720p.mkv
Archer.S01E07.720p.mkv
Archer.S01E08.720p.mkv
Archer.S01E09.720p.mkv
Archer.S01E10.720p.mkv
What am I missing? Does the rename command have some funky deal where it can't do RegEx?

Just wondering...

thanks in advance
 
Old 01-18-2012, 04:27 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 206Reputation: 206Reputation: 206
You probably have the old version of rename that doens't take a regex. You want the one from the Perl distribution.
 
1 members found this post helpful.
Old 01-18-2012, 08:16 PM   #3
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 346

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by jhwilliams View Post
You probably have the old version of rename that doens't take a regex. You want the one from the Perl distribution.
Ugh... yup, Fedora rename program doesn't support RegExp

Code:
$ rename -V
rename from util-linux 2.20.1
Download Perl version of rename

http://forums.fedoraforum.org/showthread.php?t=199949
http://wiki.linuxquestions.org/wiki/Rename

Wow that's so weak!

Thanks....

Last edited by thund3rstruck; 01-18-2012 at 08:48 PM. Reason: Added download link
 
Old 01-19-2012, 09:00 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
As mentioned, the "rename" that uses that syntax is actually the prename perl script. It comes standard with the perl package, in Debian-based systems at least, and it's automatically aliaed to rename through the alternatives system.

If you have perl installed on Fedora or another non-debian system, I really want to know if also supplies prename for you too, but just doesn't set it up as the default.
 
Old 01-19-2012, 10:06 AM   #5
thund3rstruck
Member
 
Registered: Nov 2005
Location: East Coast, USA
Distribution: Fedora 18, Slackware64 13.37, Windows 7/8
Posts: 346

Original Poster
Rep: Reputation: 38
Quote:
Originally Posted by David the H. View Post
If you have perl installed on Fedora or another non-debian system, I really want to know if also supplies prename for you too, but just doesn't set it up as the default.
I have perl installed and I had no prename script. I had to download it manually and then move it to /usr/local/bin

Code:
$ locate prename
/home/lisa.bailey/Downloads/prename.txt
/usr/local/bin/prename

$ find / -type f -iname prename* 2>/dev/null
/usr/local/bin/prename
/home/lisa.bailey/Downloads/prename.txt
 
  


Reply

Tags
rename, sed


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rename with sed in 13.0 cmk77 Slackware 8 12-05-2011 12:51 PM
Traverse the file system and Rename (xargs or sed?) sahil.jammu Linux - General 19 05-25-2011 10:15 AM
[SOLVED] sed and rename text in file cober Programming 2 02-10-2011 03:30 PM
Using Sed to Rename A Group of Files smithjb Programming 6 05-03-2009 09:27 PM
how to rename files using sed? seimour Linux - Newbie 1 05-02-2007 01:46 AM


All times are GMT -5. The time now is 04:48 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration