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

First of all, I shouldn't even have to worry about the full path when using File::Find, right? The docs say, that File::Find uses chdir() to switch to the directory of the file. So, shouldn't I be able to use $_ inside wanted() as the oldname argument for rename()?

That would leave me with a single path to worry about. In that case what do I need to enter on the command line to move the file to the directory:

/Users/me/Pictures/a b c d

Replies are listed 'Best First'.
Re^5: File::Find problems
by ikegami (Patriarch) on Jan 15, 2010 at 08:28 UTC
    What command line? I thought you were using rename
    rename($_, "/Users/me/Pictures/a b c d/$_")

      All I am trying to do is move some files from an external usb drive to a directory on my computer that I enter on the command line when prompted.

      In other words:

      chomp(my $destination = <STDIN>);

      Yes, I have given up on trying to understand what is going on. Does rename() send the string to the shell? Hence, the paths used as arguments for rename() need to have the spaces escaped? How many slashes do you need to produce a literal slash, 2, 4, 7?

        <STDIN> doesn't read from the command line. The command line isn't even a stream. The command line is placed in @ARGV. If you're getting it via STDIN, typing
        $ foo.pl /Users/me/Pictures/a b c d
        is fine. If you're passing it via the command line, you'll need to convert the string into something a string literal your shell will interpret as the appropriate string. For bash, you can use
        $ foo.pl /Users/me/Pictures/a\ b\ c\ d $ foo.pl '/Users/me/Pictures/a b c d' # Use '\'' for single quotes $ foo.pl "/Users/me/Pictures/a b c d" # Will interpolate like Perl

        Does rename() send the string to the shell?

        No

        Hence, the paths used as arguments for rename() need to have the spaces escaped?

        rename takes two strings, and they must be paths. You may need escaping to create the strings, but that's got nothing to with rename.

        How many slashes do you need to produce a literal slash, 2, 4, 7?

        Literal is what is typed, not what's produced. From what? Which slash?