Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Recursive Copy using File::Find, File::Copy

Expand Messages
  • skchoeonearth
    Thanks for the reply. It s good to see that you have TT.tif in your target directory which means the copy worked. In my case, no file is copied to target
    Message 1 of 7 , Jun 16, 2010
    • 0 Attachment
      Thanks for the reply.

      It's good to see that you have TT.tif in your target directory which
      means the copy worked.

      In my case, no file is copied to target folder. The repetition of
      TT.tif is not intentional. It is just for testing of the first copy.

      Basically I don't know why I get error message
      "COPY result=0:No such file or directory". As long as I know, result=0 means copy failed.

      S.

      --- In perl-beginner@yahoogroups.com, Donald Korrecta <draktrax@...> wrote:
      >
      > I'm not completely certain that copy failed.
      > I changed the source file to my Perl directory and the target to a file in a documents folder.
      > I got one "TT.tif" file in that folder. (Can't open it but ...)
      > The output to STDOUT was:
      >
      > The file is found: (name of file)
      > COPY result=0:No such file or directory | cpresult: 0
      >
      > for EVERY file in the directory. Is this repetition intentional?
      > Are you searching for specific criteria?
      >
      > still just dabbling aloooong - draktrax
      >
      > --- On Thu, 6/10/10, skchoeonearth <skchoe@...> wrote:
      >
      > From: skchoeonearth <skchoe@...>
      > Subject: [PBML] Recursive Copy using File::Find, File::Copy
      > To: perl-beginner@yahoogroups.com
      > Date:
      > Thursday, June 10, 2010, 5:45 PM
      >
      >
      >
      >
      >
      >
      >
      >  
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > Hi,
      >
      > when I use find() in File::Find,
      >
      > copy() always fails to find the source file w/ "No such file or directory" message.
      >
      >
      >
      > Here's the script:
      >
      >
      >
      > use File::Find;
      >
      > use File::Copy;
      >
      >
      >
      > $dir = "V:/USU-BrayFilmNegatives/Batch_2-8_Original_16bit_1200ppi";
      >
      >
      >
      > find(\&edits, $dir);
      >
      >
      >
      > sub edits() {
      >
      >
      >
      > $fullpath = $File::Find::name;
      >
      > if(-e $fullpath) {
      >
      > print "The file is found: $fullpath\n";
      >
      > $cpresult = copy ($fullpath , "TT.tif");
      >
      > print "COPY result = $?:$! | cpresult: $cpresult\n";
      >
      > }
      >
      > else {
      >
      > print "The file in NOT found: $fullpath\n";
      >
      > }
      >
      > }
      >
      >
      >
      > As you see, the existence check has passed, but inside of if(),
      >
      > the print says:
      >
      > "COPY result = 0:No such file or directory | cpresult: 1"
      >
      >
      >
      > What does 0 means, and what does 1 means as a value of $cpresult?
      >
      >
      >
      > Thank you.
      >
    • Donald Korrecta
      After a little mental elbow grease I believe I have a partial answer to your dilemma. The question is this: Why are you copying pathnames to an image file? I
      Message 2 of 7 , Jun 17, 2010
      • 0 Attachment
        After a little mental elbow grease I believe I have a partial answer to your dilemma.
        The question is this: Why are you copying pathnames to an image file?
        I changed the second argument to copy and set it to a file created in my docs.
        The  output reads:
        COPY result =  0 : cpresult 1
        for all but the first two files in my source and looking in the target file I see the names
        of the copied files listed.
        ( I put a pause after the second print so I could read the output.)
        Hope this is of use to you.
        Also, if the exit status is what the first half of the second print is supposed to give,
        then 0 means success.
        still dabbling - draktrax
        --- On Wed, 6/16/10, skchoeonearth <skchoe@...> wrote:

        From: skchoeonearth <skchoe@...>
        Subject: Re: [PBML] Recursive Copy using File::Find, File::Copy
        To: perl-beginner@yahoogroups.com
        Date: Wednesday, June 16, 2010, 11:07 AM







         









        Thanks for the reply.



        It's good to see that you have TT.tif in your target directory which

        means the copy worked.



        In my case, no file is copied to target folder. The repetition of

        TT.tif is not intentional. It is just for testing of the first copy.



        Basically I don't know why I get error message

        "COPY result=0:No such file or directory". As long as I know, result=0 means copy failed.



        S.



        --- In perl-beginner@yahoogroups.com, Donald Korrecta <draktrax@...> wrote:

        >

        > I'm not completely certain that copy failed.

        > I changed the source file to my Perl directory and the target to a file in a documents folder.

        > I got one "TT.tif" file in that folder. (Can't open it but ...)

        > The output to STDOUT was:

        >

        > The file is found: (name of file)

        > COPY result=0:No such file or directory | cpresult: 0

        >

        > for EVERY file in the directory. Is this repetition intentional?

        > Are you searching for specific criteria?

        >

        > still just dabbling aloooong - draktrax

        >

        > --- On Thu, 6/10/10, skchoeonearth <skchoe@...> wrote:

        >

        > From: skchoeonearth <skchoe@...>

        > Subject: [PBML] Recursive Copy using File::Find, File::Copy

        > To: perl-beginner@yahoogroups.com

        > Date:

        > Thursday, June 10, 2010, 5:45 PM

        >

        >

        >

        >

        >

        >

        >

        >  

        >

        >

        >

        >

        >

        >

        >

        >

        >

        > Hi,

        >

        > when I use find() in File::Find,

        >

        > copy() always fails to find the source file w/ "No such file or directory" message.

        >

        >

        >

        > Here's the script:

        >

        >

        >

        > use File::Find;

        >

        > use File::Copy;

        >

        >

        >

        > $dir = "V:/USU-BrayFilmNegatives/Batch_2-8_Original_16bit_1200ppi";

        >

        >

        >

        > find(\&edits, $dir);

        >

        >

        >

        > sub edits() {

        >

        >

        >

        > $fullpath = $File::Find::name;

        >

        > if(-e $fullpath) {

        >

        > print "The file is found: $fullpath\n";

        >

        > $cpresult = copy ($fullpath , "TT.tif");

        >

        > print "COPY result = $?:$! | cpresult: $cpresult\n";

        >

        > }

        >

        > else {

        >

        > print "The file in NOT found: $fullpath\n";

        >

        > }

        >

        > }

        >

        >

        >

        > As you see, the existence check has passed, but inside of if(),

        >

        > the print says:

        >

        > "COPY result = 0:No such file or directory | cpresult: 1"

        >

        >

        >

        > What does 0 means, and what does 1 means as a value of $cpresult?

        >

        >

        >

        > Thank you.

        >

























        [Non-text portions of this message have been removed]
      • Donald Korrecta
        Actually, the output reads: COPY result = 0  | cpresult: 1 for all but the first two and any file that has already been copied. ... From: Donald Korrecta
        Message 3 of 7 , Jun 17, 2010
        • 0 Attachment
          Actually, the output reads:
          COPY result = 0  | cpresult: 1
          for all but the first two and any file that has already been copied.

          --- On Thu, 6/17/10, Donald Korrecta <draktrax@...> wrote:

          From: Donald Korrecta <draktrax@...>
          Subject: Re: [PBML] Recursive Copy using File::Find, File::Copy
          To: perl-beginner@yahoogroups.com
          Date: Thursday, June 17, 2010, 5:03 AM







           









          After a little mental elbow grease I believe I have a partial answer to your dilemma.

          The question is this: Why are you copying pathnames to an image file?

          I changed the second argument to copy and set it to a file created in my docs.

          The  output reads:

          COPY result =  0 : cpresult 1

          for all but the first two files in my source and looking in the target file I see the names

          of the copied files listed.

          ( I put a pause after the second print so I could read the output.)

          Hope this is of use to you.

          Also, if the exit status is what the first half of the second print is supposed to give,

          then 0 means success.

          still dabbling - draktrax

          --- On Wed, 6/16/10, skchoeonearth <skchoe@...> wrote:



          From: skchoeonearth <skchoe@...>

          Subject: Re: [PBML] Recursive Copy using File::Find, File::Copy

          To: perl-beginner@yahoogroups.com

          Date: Wednesday, June 16, 2010, 11:07 AM



           



          Thanks for the reply.



          It's good to see that you have TT.tif in your target directory which



          means the copy worked.



          In my case, no file is copied to target folder. The repetition of



          TT.tif is not intentional. It is just for testing of the first copy.



          Basically I don't know why I get error message



          "COPY result=0:No such file or directory". As long as I know, result=0 means copy failed.



          S.



          --- In perl-beginner@yahoogroups.com, Donald Korrecta <draktrax@...> wrote:



          >



          > I'm not completely certain that copy failed.



          > I changed the source file to my Perl directory and the target to a file in a documents folder.



          > I got one "TT.tif" file in that folder. (Can't open it but ...)



          > The output to STDOUT was:



          >



          > The file is found: (name of file)



          > COPY result=0:No such file or directory | cpresult: 0



          >



          > for EVERY file in the directory. Is this repetition intentional?



          > Are you searching for specific criteria?



          >



          > still just dabbling aloooong - draktrax



          >



          > --- On Thu, 6/10/10, skchoeonearth <skchoe@...> wrote:



          >



          > From: skchoeonearth <skchoe@...>



          > Subject: [PBML] Recursive Copy using File::Find, File::Copy



          > To: perl-beginner@yahoogroups.com



          > Date:



          > Thursday, June 10, 2010, 5:45 PM



          >



          >



          >



          >



          >



          >



          >



          >  



          >



          >



          >



          >



          >



          >



          >



          >



          >



          > Hi,



          >



          > when I use find() in File::Find,



          >



          > copy() always fails to find the source file w/ "No such file or directory" message.



          >



          >



          >



          > Here's the script:



          >



          >



          >



          > use File::Find;



          >



          > use File::Copy;



          >



          >



          >



          > $dir = "V:/USU-BrayFilmNegatives/Batch_2-8_Original_16bit_1200ppi";



          >



          >



          >



          > find(\&edits, $dir);



          >



          >



          >



          > sub edits() {



          >



          >



          >



          > $fullpath = $File::Find::name;



          >



          > if(-e $fullpath) {



          >



          > print "The file is found: $fullpath\n";



          >



          > $cpresult = copy ($fullpath , "TT.tif");



          >



          > print "COPY result = $?:$! | cpresult: $cpresult\n";



          >



          > }



          >



          > else {



          >



          > print "The file in NOT found: $fullpath\n";



          >



          > }



          >



          > }



          >



          >



          >



          > As you see, the existence check has passed, but inside of if(),



          >



          > the print says:



          >



          > "COPY result = 0:No such file or directory | cpresult: 1"



          >



          >



          >



          > What does 0 means, and what does 1 means as a value of $cpresult?



          >



          >



          >



          > Thank you.



          >



          [Non-text portions of this message have been removed]
        • Donald Korrecta
          OK unless I m completely off my noodle this is close(?) to what you re looking for: use File::Find; use File::Copy; $dir = - source
          Message 4 of 7 , Jun 20, 2010
          • 0 Attachment
            OK unless I'm completely off my noodle this is close(?) to what you're looking for:

            use File::Find;
            use File::Copy;

            $dir = "-> source <-"  #source file
             
            find(\&edits, $dir);

            sub edits()
            {
                $fullpath = $File::Find::name = "-> specific file criteria <-"; #what EXACTLY you wish to copy
                if(-e $fullpath)
                {
                    print "The file is found: $fullpath\n";
                    $cpresult = copy($fullpath, " -> Target <-");    # - where you want the copy to go
                    printf "COPY result = $?:$! | cpresult: $cpresult \n";
                    sleep(2);  #easier to read output!
                }   
                else
                {    print "The file is NOT found: $fullpath\n";}
            }

            --- On Thu, 6/17/10, Donald Korrecta <draktrax@...> wrote:

            From: Donald Korrecta <draktrax@...>
            Subject: Re: [PBML] Recursive Copy using File::Find, File::Copy
            To: perl-beginner@yahoogroups.com
            Date: Thursday, June 17, 2010, 5:26 AM







             









            Actually, the output reads:

            COPY result = 0  | cpresult: 1

            for all but the first two and any file that has already been copied.



            --- On Thu, 6/17/10, Donald Korrecta <draktrax@...> wrote:



            From: Donald Korrecta <draktrax@...>

            Subject: Re: [PBML] Recursive Copy using File::Find, File::Copy

            To: perl-beginner@yahoogroups.com

            Date: Thursday, June 17, 2010, 5:03 AM



             



            After a little mental elbow grease I believe I have a partial answer to your dilemma.



            The question is this: Why are you copying pathnames to an image file?



            I changed the second argument to copy and set it to a file created in my docs.



            The  output reads:



            COPY result =  0 : cpresult 1



            for all but the first two files in my source and looking in the target file I see the names



            of the copied files listed.



            ( I put a pause after the second print so I could read the output.)



            Hope this is of use to you.



            Also, if the exit status is what the first half of the second print is supposed to give,



            then 0 means success.



            still dabbling - draktrax



            --- On Wed, 6/16/10, skchoeonearth <skchoe@...> wrote:



            From: skchoeonearth <skchoe@...>



            Subject: Re: [PBML] Recursive Copy using File::Find, File::Copy



            To: perl-beginner@yahoogroups.com



            Date: Wednesday, June 16, 2010, 11:07 AM



             



            Thanks for the reply.



            It's good to see that you have TT.tif in your target directory which



            means the copy worked.



            In my case, no file is copied to target folder. The repetition of



            TT.tif is not intentional. It is just for testing of the first copy.



            Basically I don't know why I get error message



            "COPY result=0:No such file or directory". As long as I know, result=0 means copy failed.



            S.



            --- In perl-beginner@yahoogroups.com, Donald Korrecta <draktrax@...> wrote:



            >



            > I'm not completely certain that copy failed.



            > I changed the source file to my Perl directory and the target to a file in a documents folder.



            > I got one "TT.tif" file in that folder. (Can't open it but ...)



            > The output to STDOUT was:



            >



            > The file is found: (name of file)



            > COPY result=0:No such file or directory | cpresult: 0



            >



            > for EVERY file in the directory. Is this repetition intentional?



            > Are you searching for specific criteria?



            >



            > still just dabbling aloooong - draktrax



            >



            > --- On Thu, 6/10/10, skchoeonearth <skchoe@...> wrote:



            >



            > From: skchoeonearth <skchoe@...>



            > Subject: [PBML] Recursive Copy using File::Find, File::Copy



            > To: perl-beginner@yahoogroups.com



            > Date:



            > Thursday, June 10, 2010, 5:45 PM



            >



            >



            >



            >



            >



            >



            >



            >  



            >



            >



            >



            >



            >



            >



            >



            >



            >



            > Hi,



            >



            > when I use find() in File::Find,



            >



            > copy() always fails to find the source file w/ "No such file or directory" message.



            >



            >



            >



            > Here's the script:



            >



            >



            >



            > use File::Find;



            >



            > use File::Copy;



            >



            >



            >



            > $dir = "V:/USU-BrayFilmNegatives/Batch_2-8_Original_16bit_1200ppi";



            >



            >



            >



            > find(\&edits, $dir);



            >



            >



            >



            > sub edits() {



            >



            >



            >



            > $fullpath = $File::Find::name;



            >



            > if(-e $fullpath) {



            >



            > print "The file is found: $fullpath\n";



            >



            > $cpresult = copy ($fullpath , "TT.tif");



            >



            > print "COPY result = $?:$! | cpresult: $cpresult\n";



            >



            > }



            >



            > else {



            >



            > print "The file in NOT found: $fullpath\n";



            >



            > }



            >



            > }



            >



            >



            >



            > As you see, the existence check has passed, but inside of if(),



            >



            > the print says:



            >



            > "COPY result = 0:No such file or directory | cpresult: 1"



            >



            >



            >



            > What does 0 means, and what does 1 means as a value of $cpresult?



            >



            >



            >



            > Thank you.



            >



            [Non-text portions of this message have been removed]

























            [Non-text portions of this message have been removed]
          • Jenda Krynicky
            From: skchoeonearth ... Unless this is meant as an exercise you should simply use File::Copy::Recursive (portable) or Win32::FileOp (Windows
            Message 5 of 7 , Jun 24, 2010
            • 0 Attachment
              From: "skchoeonearth" <skchoe@...>
              > Hi,
              > when I use find() in File::Find,
              > copy() always fails to find the source file w/ "No such file or directory" message.

              Unless this is meant as an exercise you should simply use
              File::Copy::Recursive (portable) or Win32::FileOp (Windows only).

              Jenda
              ===== Jenda@... === http://Jenda.Krynicky.cz =====
              When it comes to wine, women and song, wizards are allowed
              to get drunk and croon as much as they like.
              -- Terry Pratchett in Sourcery
            Your message has been successfully submitted and would be delivered to recipients shortly.