Thanks for hanging in there with me.

I used File::Copy's move(), and that seemed to work. But it moved all of the files except two. All the files I want to move are in one directory and have a .NEF extension. They are mixed in with other files having a .JPG or .AVI extension.

I had my script print out the name of each file before moving it. Here is part of the output:

DSC_0102.NEF DSC_0098.NEF DSC_0103.NEF DSC_0104.NEF DSC_0101.NEF Couldn't move DSC_0101.NEF: Operation not permitted at 2perl.pl line 3 +0 ... ... DSC_0135.NEF DSC_0136.NEF Couldn't move DSC_0136.NEF: Operation not permitted at 2perl.pl line 3 +0. DSC_0137.NEF ... ...

Here is my code:

use strict; use warnings; use 5.010; use File::Find; use File::Copy; my $destination_dir = "/Users/me/Pictures/a b c d"; my $volume_name = "/Volumes/Volume\\ Name"; #need double slash in path for glob() in next line #(see glob docs) for (glob "$volume_name/*") { if (-d) { find(\&wanted, $_); } } sub wanted { if (-f && /\.NEF$/) { my $new_path = "$destination_dir/$_"; say $_; move $_, $new_path or warn "Couldn't move $_: $!"; #**LINE 30 +*** } }

In reply to Re^10: File::Find problems by 7stud
in thread File::Find problems by 7stud

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.