CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
'Permission Denied'?

 



jrap
Deleted

Jan 8, 2001, 2:42 PM

Post #1 of 2 (431 views)
'Permission Denied'? Can't Post

Greetings,
I am creating a script to rename mp3's, and have gotten into a problem that I cannot seem to solve. The code is attached with this message.


The problem is that in if($id[0] && $id[1]) , I get the error "Permission Denied" for some reason. If $_ is passed to the elseif(), it renames properly. I know that the file ($_) exists through testing with '-e', and I know that $id[0] and $id[1] contain the proper information. Any ideas ?

I should note that I am developing this on Windows.

Any help would be much appretiated.
Thanks

nope


jrap
Deleted

Jan 8, 2001, 5:41 PM

Post #2 of 2 (428 views)
Re: 'Permission Denied'? [In reply to] Can't Post

The attachment didn't seem to work. Here is the code:


Code
#!/usr/bin/perl -w 
use strict;

print "Enter the <dir> where the mp3's are found: ";
chomp (my $dir = <stdin>);

chdir($dir) or die "Canot change $dir :$!\n";
opendir(DIR,".") or die "Cannot open $dir:$!\n";
my @songs=grep(/\.mp3$/i,readdir(DIR));
closedir(DIR);

foreach(@songs)
{
my @id = id3check($_);
if($id[0] && $id[1])
{
rename $_,"$id[0] - $id[1].mp3" or print "$_ : $!\n"; next;
print "$id[0] - $id[1].mp3\n";
}
elsif($_ =~ m/(\s*[^-]*)-\s*([^.]*).mp3/i)
{
$id[0] = $1;
$id[1] = $2;
s/\s*$|^\s*|{|}//g for ($id[0],$id[1]);
rename $_,"$id[0] - $id[1].mp3";
print "$id[0] - $id[1].mp3\n";
}
else
{
print "Couldn't rename $_\n";
}
}
sub id3check
{
open(SONG, "<$_[0]");
my $tag;
my @id;
binmode SONG;
seek SONG,-128,2;
read SONG,$tag,3;
if($tag eq "TAG")
{
read(SONG,$id[1],30);
read(SONG,$id[0],30);
s/\s*$|{|}//g for ($id[0],$id[1]);
return @id;
}
close(SONG);
}
</pre><p>

nope

(This post was edited by Jasmine on Jan 11, 2001, 5:32 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives