LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 09-20-2016, 08:01 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Rename files by replacing text


I have a lot of rename examples to go by, but not of this type.

I want to replace the MVI with Jakob_Football

Quote:
MVI_0045.MP4
 
Old 09-20-2016, 08:10 PM   #2
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
find -type f -name '*.MP4' | rename 's/MVI/Jakob_Football/'
 
Old 09-21-2016, 02:32 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,306
Blog Entries: 3

Rep: Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720
Quote:
Originally Posted by Fixit7 View Post
find -type f -name '*.MP4' | rename 's/MVI/Jakob_Football/'
Video and music can often have difficult names with spaces, quotes, apostrophes, and other weird characters. So if you are using "find" to limit yourself to regular files, you can use -print0 to use a null for a separator and then send it to "xargs" with the -0 or --null option:

Code:
find -type f -name '*.MP4' -print0 | xargs --null rename 's/MVI/Jakob_Football/'
It might be enough to just use rename, though:

Code:
rename -n 's/MVI/Jakob_Football/' *.MP4
and take away the -n when you see it is working the way you want.
 
  


Reply



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 files using text list carlosestensser Fuduntu 6 06-06-2012 12:33 PM
Replacing text in files without using sed dfresh4130 Programming 16 05-28-2009 10:13 AM
Rename 100+ files from a text file AGazzaz Linux - Software 9 09-26-2008 12:41 AM
Replacing text in multiple files ? centosfan Linux - General 10 09-20-2008 07:25 AM
Rename files by stripping text from either desired string? varney Linux - General 2 02-21-2008 10:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 11:14 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration