in reply to Re^2: How to get filesystem ownerships
in thread How to get filesystem ownerships

Sounds like the problem lies in this regex:
my ($owner, $file) = ($line =~ /\\(\w+)\s+(.*)$/)[0,1];
I get Machine\User for dir /Q.
VIPER\Marshall   Some filename with spaces.txt

do a "dir /Q" from command line and post result here and the regex can be tweaked and yes it can be frustrating.

Replies are listed 'Best First'.
Re^4: How to get filesystem ownerships
by Anonymous Monk on Apr 24, 2010 at 17:28 UTC
    C:\>dir /Q Volume in drive C has no label. Volume Serial Number is C4F5-E00C Directory of C:\ 04/22/2010 03:50 PM <DIR> BUILTIN\Administrators Apps 09/18/2006 04:43 PM 24 BUILTIN\Administrators autoexec +.bat 01/20/2008 09:24 PM 333,203 NT SERVICE\TrustedInstabootmgr 09/18/2006 04:43 PM 10 BUILTIN\Administrators config.s +ys 12/02/2008 02:34 PM <DIR> NT AUTHORITY\SYSTEM HPACC 12/02/2008 02:45 PM <DIR> NT AUTHORITY\SYSTEM Logs 12/02/2008 02:34 PM <DIR> NT AUTHORITY\SYSTEM MSDERelA 12/02/2008 02:34 PM <DIR> NT AUTHORITY\SYSTEM Oracle 01/20/2008 09:32 PM <DIR> ... PerfLogs 04/12/2010 12:35 PM <DIR> NT AUTHORITY\SYSTEM Perl 03/28/2010 05:20 PM <DIR> NT SERVICE\TrustedInstaProgram +Files 12/02/2008 02:34 PM <DIR> NT AUTHORITY\SYSTEM Sun 04/22/2010 03:41 PM <DIR> BUILTIN\Administrators temp 01/25/2010 10:52 AM <DIR> BUILTIN\Administrators Users 03/23/2010 08:36 AM <DIR> NT SERVICE\TrustedInstaWindows 05/04/2007 08:41 AM 150 BUILTIN\Administrators YServer. +txt
    Thanks again!!!!!
      This works!

      #!/usr/bin/perl -w use strict; $| =1; my $path = 'C:\temp'; my @lines = `"dir /Q $path"`; foreach my $line (@lines) { next unless $line =~ m|^\d+/\d+|; $line =~ s/^.{39}//; my ($owner, $file) = $line =~ /^(.{23})(.*)$/; $owner =~ s/\s*$//; $file =~ s/\s*$//; print "$owner\t$file\n"; }

      Thanks Mojotoad!