Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Script to add extension to filename

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-22-2011   -   Original Discussion by repiv
repiv's Unix or Linux Image
repiv repiv is offline
Registered User
 
Join Date: Feb 2011
Last Activity: 27 January 2012, 5:21 PM EST
Posts: 6
Thanks: 5
Thanked 0 Times in 0 Posts
Script to add extension to filename

Hi all,

I have a folder with a bunch of files in them, and I would like to add an extension (.mp3)to all these filenames. The folder has only files that I'd like .mp3 added to.

It looks something like this:

Intput:

Code:
File1
File2
File3

Output:

Code:
File1.mp3
File2.mp3
File3.mp3

Thanks in advance!
Sponsored Links
    #2  
Old Unix and Linux 07-22-2011   -   Original Discussion by repiv
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 13 December 2017, 10:16 AM EST
Location: Saskatchewan
Posts: 22,546
Thanks: 1,159
Thanked 4,286 Times in 3,955 Posts

Code:
find ./folder -type f -exec mv '{}' '{}.mp3' ';'

The Following User Says Thank You to Corona688 For This Useful Post:
repiv (07-22-2011)
Sponsored Links
    #3  
Old Unix and Linux 07-22-2011   -   Original Discussion by repiv
mauregato's Unix or Linux Image
mauregato mauregato is offline
Registered User
 
Join Date: Apr 2010
Last Activity: 5 October 2017, 9:27 AM EDT
Location: Bcn\Spain
Posts: 16
Thanks: 1
Thanked 3 Times in 3 Posts
Hi,
you can try

Code:
for i in File*
do
mv $i $i.mp3
done


Last edited by radoulov; 07-22-2011 at 06:37 PM.. Reason: Code tags, please!
The Following User Says Thank You to mauregato For This Useful Post:
repiv (07-22-2011)
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
removing the filename extension daflore Shell Programming and Scripting 5 03-03-2011 05:43 PM
cut filename extension Essbaumer Shell Programming and Scripting 4 07-29-2010 06:18 AM
script takes the whole filename instead of just extension wolverine999 UNIX for Dummies Questions & Answers 1 05-20-2009 03:49 PM
changing filename extension Hiso Shell Programming and Scripting 3 01-24-2009 09:02 AM
separating filename and extension lucaspewkas Shell Programming and Scripting 2 04-06-2007 08:07 AM



All times are GMT -4. The time now is 02:52 PM.