Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 2nd December 2011, 05:21
bschultz bschultz is offline
Senior Member
 
Join Date: Jul 2006
Posts: 220
Thanks: 11
Thanked 10 Times in 10 Posts
Default Batch Rename all mp3's in a directory

I need to rename several hundred mp3's in a directory. I've tried this php script...but it seems to have missed every file from 19 to 29 (119-129, 219-229, 319-329 etc).

The original names are in no particular order or fashion in how they're named.

What's my best choice to rename these files to song1.mp3, song2.mp3 song3.mp3 etc.?

PHP Code:
<?php
$i 
1;
foreach (
glob("/xmas/*.mp3") as $filename) {
copy ("$filename""/newpopaudio/xmas$i.mp3");
$i++;
}
?>
Reply With Quote
Sponsored Links
  #2  
Old 2nd December 2011, 20:10
nbhadauria nbhadauria is offline
Member
 
Join Date: Aug 2010
Location: New Delhi, India
Posts: 79
Thanks: 1
Thanked 13 Times in 13 Posts
Send a message via Skype™ to nbhadauria
Default

use this ..

i=0
for song in *.mp3
do
mv $song song$i.mp3
((i++))
done
__________________
Best
Nitin Bhadauria
Reply With Quote
  #3  
Old 3rd December 2011, 12:14
nbhadauria nbhadauria is offline
Member
 
Join Date: Aug 2010
Location: New Delhi, India
Posts: 79
Thanks: 1
Thanked 13 Times in 13 Posts
Send a message via Skype™ to nbhadauria
 
Default

go in the directory and run the script.
__________________
Best
Nitin Bhadauria
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webmin upgrade lishaw1968 Installation/Configuration 15 26th August 2010 15:23
Email problem 'Cannot set my user or group id.' (using ISPConfig 3 + OpenSuSE 11.2) urosm Installation/Configuration 5 19th June 2010 22:41
can't help ispconfig to install please help steve51184 Installation/Configuration 17 20th February 2009 10:37
ISPConfig install issues... flyingaggie Installation/Configuration 2 18th July 2008 10:46
Systemimager (rsync) doesn't copy all comedit HOWTO-Related Questions 11 19th January 2007 17:17


All times are GMT +2. The time now is 23:44.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.