blackadder has asked for the wisdom of the Perl Monks concerning the following question:

O’ holly ones,….Greetings. I have the following script
#! Path to perl.exe -w use strict; use diagnostics; use warnings 'all'; use Win32; use Win32::OLE; use Win32::ODBC; use File::Find; use File::stat; use time::localtime; use vars qw/%data/; $data{path} = $ARGV[0]; system("cls"); print "\n\nTarget Path=> $data{path}\n"; find sub { print $File::Find::name, $/ if -f _; },$data{path};
What I would like to obtain is a display like so if my @ARGV1 is adrive letter or folder.
drive\folers1 File1.snd File2.sop File3.xxs dive\folder2 File10.dod File34.opo . . .
And so on…

Can you please enlighten me on to how Can I achieve this?

Also, And more importantly if these files are hosted ona DFS share how can I obtain the UNC path to those files.

Your help is really really highly appreciated and example would go along way….Thanks.

**************UPDATE*************

A bit of background info



I need to write a script that stats only files. For example I have a drive “t:\” (Which is a DFS represented shared area). And I need to get a list of all files is this drive and their full path, their sizes, creation date, last modified date, last accessed date, the owner of this file, and it UNC path (i.e which server this file is on).

Now in this bit of code
find sub { print $File::Find::name, $/ if -f _; },$data{path};
I need to do something like the below (not sure how)
my $file_stat = stat ($File::Find::name); print $creation_date; print $modified_date; print $accessed_date; print $file_owner; print $Full_file_path; print $file_size
Since I haven't got a clue on how to begin and what to do, so your help - I couldn't stress it any more - is very very vital to me.

Thanks
Blackadder

Replies are listed 'Best First'.
Re: Stats for files using File::Find and DFS information
by NetWallah (Canon) on Jul 12, 2005 at 05:40 UTC
    I have not tried this on DFS, but it works fine on a regular file system, and there is no reason for it to do otherwise on DFS :
    use strict; use diagnostics; use warnings 'all'; use File::Find; use File::stat; use Time::localtime; system("cls"); for (@ARGV){ find sub { -d and print "\n$File::Find::name ================\n"; return unless -f; my $sb = stat($_); my $mt = localtime $sb->mtime; my $ct = localtime $sb->ctime; printf " %s, %s bytes, Mod:%02d/%02d/%02d Creat:%02d/%02 +d/%02d\n", $_, $sb->size, $mt->mon()+1,$mt->mday(),$mt->year %100, $ct->mon()+1,$ct->mday(),$ct->year %100 ; } ,$_ ; }

         "Income tax returns are the most imaginative fiction being written today." -- Herman Wouk

      Thanks,...This is good.

      But how about the file owners? Any idea how can I obtain this information please?

      Regards

      Blackadder
        Just read one off Tye's posts, Stat() under Win32 will always return 0 for file onwership,...need to use Win32::Perms.

        Thanks

        Blackadder