in reply to Re^9: File::Find problems
in thread File::Find problems

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 +*** } }

Replies are listed 'Best First'.
Re^11: File::Find problems
by ikegami (Patriarch) on Jan 15, 2010 at 23:31 UTC
    A permission problem could indicate another process has the file open.
      Here is what I discovered. I'm using mac os x 10.4.11, and I right clicked on one of the files that wouldn't move, and I chose Get Info. That popped up a dialog box that displayed info about the file. In the General section, in addition to the file size, path, creation date, etc., there were two checkboxes that said: Stationery Pad(whatever that is) and Locked. Locked was checked. A random sampling of 5 files that were moved had the Locked checkbox unchecked. So I unchecked Locked in the dialog box for both files and reran the script. This time the script successfully moved the two files.

      What the heck is Locked referring to? Why the heck would two files be Locked? The files are on an SD digital camera card.

      Hmmm...I wonder if that has to do with tagging the files in the camera, so they can't be erased?

        What the heck is Locked referring to?

        Sounds like some kind of read-only flag. You might be able to use chmod to remove it.

        I wonder if that has to do with tagging the files in the camera, so they can't be erased?

        The camera might protect the files by making them read-only at the file-system level. Efficient, simple, portable.