in reply to Quickest way to get a list of all folders in a directory
Your backslashes in double quotes represents an escaped character. You could use single quotes:
'\\pcname-vm\c$\program files\adobe'
Or you could use double quotes with multiple escaping to compensate for the escaping:
Or, finally, you could use forward slashes:"\\\\pcname-vm\\c$\\program files\\adobe"
"//pcname-vm/c$/program files/adobe"
Also, you should remove any non-directories from your list.
use strict; use warnings; my $directory = "//pcname-vm/c$/program files/adobe"; open(NDIR, $directory) or die "Error: $!"; my @folders; while (my $filename = readdir(NDIR)) { # skip the . and .. directories next if ($filename =~ /^.+$/); my $folder = "$directory/$filename"; # skip if not a directory next if (! -d $folder); push(@folders, $filename); } close(NDIR); foreach (@folders) { print "$_\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Quickest way to get a list of all folders in a directory
by mweb (Initiate) on Aug 13, 2009 at 17:33 UTC | |
|
Re^2: Quickest way to get a list of all folders in a directory
by ig (Vicar) on Aug 13, 2009 at 17:18 UTC |