Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > can Perl on the mac do this?

can Perl on the mac do this?
Thread Tools
Forum Regular
Join Date: Aug 2002
Status: Offline
Reply With Quote
May 21, 2003, 01:51 PM
 
I hate how iTunes formats imported music via folders... I want my music to be in this format...

Band Name - Name Of Song.m4a

not Band Name / Album Name / Name Of Song.m4a

is there a Perl script for OS X that allows me to take the song names in a folder (generated by iTunes), that once initialized will ask me what I want to append my m4a files to...

example...

The Tennessee Waltz.m4a
Conquest.m4a

once the perl script is run, it will ask me what to append these files in a directory...

So I enter "Patti Page - "

so that it will convert these files to...

Patti Page - The Tennessee Waltz.m4a
Patti Page - Conquest.m4a

anyone have any ideas? This is what I have so far and a friend helped me with this, but the spaces in the file names are giving us problems.

here is the perl code:

#!/usr/bin/perl
printf "enter text to append to all files in this directory: ";
$crap = <STDIN>;
chomp($crap);
opendir(D,"./");
@files=readdir(D);
for $f (@files){
# do something else with $f
print "mv ".$f." ". $crap.$f."\n";
}
closedir(D);

thanks for any help,

Jason
     
Forum Regular
Join Date: Dec 2002
Status: Offline
Reply With Quote
May 21, 2003, 05:11 PM
 
Off the top of my head, I'd avoid using mv and the shell, that avoids the shell quoting silliness that you were probably missing.

#!/usr/bin/perl

printf "enter text to append to all files in this directory: ";
$crap = <STDIN>;
chomp($crap);
opendir(D,"./");
@files=readdir(D);
for $f (@files){
if (! -e $crap . $f) {
if (!rename($f, $crap . $f)) {
die "Bad rename.\n";
}
}
else {
die "File name \"" . $crap . $f . "\" already exists.\n";
}
}
closedir(D);
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 05:57 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2