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

That seems like a faulty path to me because the space in "Volume Name" is not escaped.

Why would you expect something other than a path from File::Find? It was escaped, it wouldn't be a path.

You need to escape something when you want to embed one thing into another. (A path in a glob pattern, a string in Perl code, a string in a command line, etc) How you escape it also dependent on what you want to embed it into. Once it's escaped, it's no longer a path. (It's a glob pattern, a Perl string literal, a shell string literal, etc)

Yes, I've decided I have NO IDEA how to deal with path names containing spaces

In a glob pattern? You've already been given two solutions. Escape the space or use bsd_glob.

I also think the error given by rename() sucks: it doesn't tell you which path is faulty.

It's not like you checking two paths is harder than checking one when you have a problem.

The system simply returns a number which represents the error message.

Replies are listed 'Best First'.
Re^4: File::Find problems
by 7stud (Deacon) on Jan 15, 2010 at 08:23 UTC

    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
      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?