opendir DI, "$dir/$parent"ordie"Can't open directory...";
while($_ = readdir(DI))
{
nextif$_ eq "."or$_ eq "..";
if(/(\w+ )(\d+)\b(\d+)\b(.*)(\d+)/)
{
print"Long File";
our$month = $1;
our$day = $2;
our$year = $3;
our$name = $5;
}
elseif(/(\w+ )(\d+)\b(\d+)\b(.*)(\d)\b/)
{
print"Short File";
our$month = $1;
our$day = $2;
our$year = $3;
our$name = $5;
}
}
}
}
print"Done";
I use Windows Vista with ActivePerl.
Basically I have a bunch of folders within a large parent folder each with two mp3 files and a txt file (which I don't care about) in this format:
Month DD YYYY . Name . ##(#)kbps . XX(X) minutes.mp3
the two mp3 files are exactly the same format that the ones with two digit minutes I want to name one way (lets say "short") and ones with 3 digits I want to name another way (lets say "long"). I also have other mp3 files which are not in this format and I cannot figure out a way to grab the length or bitrate of an mp3 file in perl (maybe someone can help with this too).
Anyway, this code does not run. I get a syntax errors at lines 28 and 38. I am using 'else if' wrong probably...
(ignore my misplaced mys and ours)
I am very new to Perl programming and would love some help. Thanks.
It's still giving me a syntax error at the else if line and the final closing bracket of the while loop.
(I'm sure you solved one problem with it though)
Oops, I missed the elsif change you mentioned...
It runs now, but I didn't get any Long File or Short File returns, just the Done.
So either my regexps are wrong, or my directory handling is wrong. Am I doing anything else wrong?
The regular expression:
(\w+ ) - the month (any amount of word characters and a space)
(\d+) - 1 or 2 numbers (the day)
\b - a boundary
(\d+) - 4 numbers (the year)
\b - a boundary
(.*) - everything up to the last numbers in the string (because its greedy
(\d+) - 2 or 3 numbers (the length)
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.