capfan
capfan

Reputation: 827

How to get the details of a file on Windows

If you open the properties of a file in Windows, there usually is a Details tab. I want to access the information on this tab, but I don't know how. Is there a module for it? Does someone has a code sniplet?

I tried to work with Win32::File's GetAttributes, but these are not the attributes I was looking for.

Upvotes: 2

Views: 1056

Answers (2)

Boontawee Home
Boontawee Home

Reputation: 1053

use Win32::OLE;

my $objShell  = Win32::OLE->new("Shell.Application") or die;
my $objFolder = $objShell->NameSpace($myDir) or die;
my $objFile   = $objFolder->ParseName($fileName) or die;

while ( $i <= 34 ) 
{
  my $propertyName  = $objFolder->GetDetailsOf($fileName,$i);
  my $propertyValue = $objFolder->GetDetailsOf($objFile,$i);
  print "$i -- $propertyName -- $propertyValue\n";
  $i++;
} 

Upvotes: 3

MC ND
MC ND

Reputation: 70943

You can instantiate a COM "Shell.Application" object. It exposes a .NameSpace(folder) method that returns a reference to the name space of the indicated folder, which holds the information you need. The retrieved instance holds a Items collection with references to each of the files in the folder, and a .GetDetailsOf(file,property) to retrieve each of the values seen in the details tab and explorer columns.

Sorry i have no idea of perl, so i can not include any working code.

Upvotes: 1

Related Questions