Kevin Zembower wrote:
> I'm trying to write a script to perform a number of actions on
> files sent to me regularly on CD-ROMs. Unfortunately, the CD-ROM is
> generated on a Windows machine, often with spaces in the directory
> names:
> [EMAIL PROTECTED]:~/RapheTask$ ls -lR /cdrom/
> /cdrom/:
> total 4
> dr-xr-xr-x    1 root     root         2048 Jan 16  2003 JPEG Covers
> dr-xr-xr-x    1 root     root         2048 Jan 16  2003 PDF Docs
>
> /cdrom/JPEG Covers:
> total 3858
> -r-xr-xr-x    1 root     root       806801 Jan 16  2003 PLUGA164.jpg
> -r-xr-xr-x    1 root     root      1475140 Jan 16  2003 PLUGA333.jpg
> -r-xr-xr-x    1 root     root       516976 Jan 16  2003 PLUGA376.jpg
> -r-xr-xr-x    1 root     root      1138129 Jan 16  2003 PLUGA403.jpg
>
> /cdrom/PDF Docs:
> total 28761
> -r-xr-xr-x    1 root     root      1154227 Jan 16  2003 PLUGA164.pdf
> -r-xr-xr-x    1 root     root      3369769 Jan 16  2003 PLUGA306.pdf
> -r-xr-xr-x    1 root     root      1394922 Jan 16  2003 PLUGA333.pdf
> -r-xr-xr-x    1 root     root      3156595 Jan 16  2003 PLUGA369.pdf
> -r-xr-xr-x    1 root     root      3308012 Jan 16  2003 PLUGA370.pdf
> -r-xr-xr-x    1 root     root      6116464 Jan 16  2003 PLUGA376.pdf
> -r-xr-xr-x    1 root     root      2167484 Jan 16  2003 PLUGA394.pdf
> -r-xr-xr-x    1 root     root      2177885 Jan 16  2003 PLUGA395.pdf
> -r-xr-xr-x    1 root     root      2884660 Jan 16  2003 PLUGA400.pdf
> -r-xr-xr-x    1 root     root      3121413 Jan 16  2003 PLUGA401.pdf
> -r-xr-xr-x    1 root     root       519212 Jan 16  2003 PLUGA403.pdf
> [EMAIL PROTECTED]:~/RapheTask$
>
> My program is this:
> [EMAIL PROTECTED]:~/RapheTask$ cat processAVimages.pl
> #! /usr/bin/perl -w
>
> use strict;
> use File::Find;
>
> sub process_file {
>    print "$File::Find::name\n";
>    #Other operations will go here
> }
>
> find(\&process_file, '/cdrom/');
>
> [EMAIL PROTECTED]:~/RapheTask$
>
> The program seems to stall when it hits the directories with spaces
> in filenames, and doesn't find the files in them:
> [EMAIL PROTECTED]:~/RapheTask$ ./processAVimages.pl
> /cdrom
> /cdrom/JPEG Covers
> /cdrom/PDF Docs
> [EMAIL PROTECTED]:~/RapheTask$
>
> When I run it on a directory without spaces in any of the
> subdirectory names, it seems to work fine.
>
> What are some suggestions for working around this behavior?  I just
> need to process the files; the directory structure will be thrown
> away. I'd like to be able to deal with what ever directory
> structure is included on the CD, and not just hard-code in specific
> directory names used.
>
> Thanks for your thoughts and suggestions.

Hi Kevin.

I believe this should work find as long as the code is as you say it is. Try
just:

  use strict;
  use warnings;

  use File::Find;

  find (sub{ print "$File::Find::name\n" }, '/full/path/to/cdrom' );

which works fine on my Windows XP machine, both bare and running Cygwin.

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to