Ken wrote:
> J. Gleixner,
>
> Thanks for your reply.
Sure. Thanks in advance for not top-posting again.
>
> Per your advise, below is the exact message from the command prompt:
> ##########
> D:\Scripts>perl Copy_pdf_pages.pl
> File mcp_1678576.pdf has 3 pages
> mcp_1678576.pdf:3
> move( mcp_1678576.pdf, D:\Scripts\1\mcp_1678576.pdf ) failed:
> Permission denied
> at Copy_pdf_pages.pl line 61.
> ##########
>
> Line 61 contains: move($file,$newfile) or die "move( $file, $newfile )
> failed: $!";.
> I changed line 60 to this: $newfile = "$newpgcount/$file";.
>
> I have tried moving the file in a command prompt and that worked fine,
> so I'm baffled why Perl is not able to move the file.
I took at look at your script again..
> unless (-d '$newpgcount')
Change that to:
unless( -d $newpgcount )
Also, if
$newpgcount=1;
$newfile = "$newpgcount/$file"
Then I'd think
die "move( $file, $newfile ) failed: $!";
Would print:
move( mcp_1678576.pdf, 1/mcp_1678576.pdf ) failed: Permission denied
but.. if the above change to your unless fails, then try something
simple, as I suggested before.
e.g. ensure the directory '1' exists and you have permissions to create
files there.
use File::Copy;
my $file = 'mcp_1678576.pdf';
my $newfile = "1/$file";
move( $file, $newfile )
or die "move( $file, $newfile ) failed: $!";