Friday 22 February 2013

VB Script: Retrieving Extended Files Properties of all files in folder, and import all attributes to Excel file.

To list extended Properties of files inside folder, use below script.

Save script in any localtion, i;e C:\Script.vbs, run below command

C:\>cscript //nologo script.vbs > report.csv

In addition, depending on the OS version, the properties are in different order and there may be many more.  Win XP has 33 standard items, but Win 7 has 286 and the order of some of them differ between the two OSs.

Script,...

--------------------------------------------------------------------------------------
Dim arrHeaders()
  
Set objShell = CreateObject("Shell.Application")Set objFolder = objShell.Namespace("D:\Database")
  
On error resume nextFor i = 0 to 287
  redim preserve arrHeaders(i)
  arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
  if err.number <> 0 then exit forNextOn error goto 0
wsh.echo "File Name" & "," & Join(arrHeaders, ",")
   
For Each strFileName in objFolder.Items
  wsh.stdout.write strFileName 
  For j = 0 to i - 1
    wsh.stdout.write "," & objFolder.GetDetailsOf(strFileName, j) 
  Next
  wsh.echo
Next


No comments:

Post a Comment