Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: File name is long to copy

by marto (Cardinal)
on Apr 26, 2020 at 13:18 UTC ( [id://11116075]=note: print w/replies, xml ) Need Help??


in reply to File name is long to copy

What error are you getting? You could be hitting some OS (which?) based path depth limit. Let perl tell you what happened:

copy( $source, $target ) or die "couldn't copy file $!";

Replies are listed 'Best First'.
Re^2: File name is long to copy
by hippo (Bishop) on Apr 26, 2020 at 13:25 UTC

    Good advice. I'd include the paths too as the longer they are the more likely it is that one of them may have a typo.

    copy( $source, $target ) or die "couldn't copy file '$source' to '$tar +get': $!";

      the other files in that folder are copied but not this, if I reduce the name of the file then it works but that is not possible for me.

        SSCCE works for me.

        use strict; use warnings; use File::Copy 'copy'; use Test::More tests => 1; my $longname = 'foo_' . ('z' x 200); open my $fh, '>', $longname; print $fh "Hello!\n"; close $fh; my $toname = 'bar_' . ('z' x 200); ok copy ($longname, $toname) or diag $!;

        Maybe your O/S or your filesystem is the problem here?

Re^2: File name is long to copy
by harishnv (Sexton) on Apr 26, 2020 at 13:26 UTC

    "could not do at C:\sandboxes\Scripts\dummy.pl line 9" the error I got. any other solution? or can I copy the folders, sub folders and files in line of code? I'm using Windows

      Which version of Windows? It doesn't look like you tried what I suggested, note the $!

      copy( $source, $target ) or die "couldn't copy file $!"; #---------------------------------------------------^

        The error is "couldn't copy file No such file or directory at C:\sandboxes\Scripts\dummy.pl line 9."

        Windows 10 and the file is present because there are other files which I copy in that directory

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116075]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found