Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for filedetails.vbs

(view source code of filedetails.vbs as plain text)

  1. Option Explicit
  2.  
  3. Dim i, intKeyLength, intMaxLength
  4. Dim objFolder, objFolderItem, objFSO, objShell
  5. Dim strFile, strFileName, strKeyName, strMsg, strParentFolder
  6.  
  7. If WScript.Arguments.Unnamed.Count = 1 Then
  8. 	strFile = WScript.Arguments.Unnamed.Item(0)
  9. Else
  10. 	Syntax
  11. End If
  12.  
  13. Set objFSO = CreateObject( "Scripting.FileSystemObject" )
  14. If objFSO.FileExists( strFile ) Then
  15. 	strFileName       = objFSO.GetFileName( strFile )
  16. 	strParentFolder   = objFSO.GetParentFolderName( strFile )
  17. 	Set objShell      = CreateObject( "Shell.Application" )
  18. 	Set objFolder     = objShell.Namespace( strParentFolder )
  19. 	Set objFolderItem = objFolder.ParseName( strFileName )
  20. 	intMaxLength      = 0
  21. 	For i = 0 To 300
  22. 		strKeyName   = objFolder.GetDetailsOf( objFolder.Items, i )
  23. 		intKeyLength = Len( strKeyName )
  24. 		If intKeyLength > intMaxLength Then intMaxLength = intKeyLength
  25. 	Next
  26. 	strMsg = "System Locale = " & GetLocale( ) & vbCrLf & vbCrLf
  27. 	For i = 0 To 300
  28. 		strKeyName = Trim( objFolder.GetDetailsOf( objFolder.Items, i ) )
  29. 		If strKeyName <> "" Then
  30. 			strMsg = strMsg _
  31. 			       & "[" & Right( "000" & i, 3 ) & "] " _
  32. 			       & Left( strKeyName & Space( intMaxLength ), intMaxLength ) _
  33. 			       & " = " _
  34. 			       & objFolder.GetDetailsOf( objFolderItem, i ) _
  35. 			       & vbCrLf
  36. 		End If
  37. 	Next
  38. 	Set objFolderItem = Nothing
  39. 	Set objFolder     = Nothing
  40. 	Set objShell      = Nothing
  41. 	WScript.Echo strMsg
  42. Else
  43. 	Syntax
  44. End If
  45. Set objFSO = Nothing
  46.  
  47.  
  48. Sub Syntax( )
  49. 	strMsg = "FileDetails.vbs,  Version 1.00" _
  50. 	       & vbCrLf _
  51. 	       & "List file details for the specified file, in the system's language" _
  52. 	       & vbCrLf & vbCrLf _
  53. 	       & "Usage:" & vbTab & "CSCRIPT.EXE  //NoLogo  FileDetails.vbs  filename" _
  54. 	       & vbCrLf _
  55. 	       & "   or:" & vbTab & "CSCRIPT.EXE  //NoLogo  FileDetails.vbs  filename > logfile 2>&1" _
  56. 	       & vbCrLf & vbCrLf _
  57. 	       & "Where:" & vbTab & "filename" & vbTab & "is the file to be examined" _
  58. 	       & vbCrLf _
  59. 	       & "      " & vbTab & "logfile " & vbTab & "is the optional log file to receive FileDetails.vbs' output" _
  60. 	       & vbCrLf & vbCrLf _
  61. 	       & "Note:" & vbTab & "Output format is in ""[index] Property Name = Value"" format." _
  62. 	       & vbCrLf _
  63. 	       & "      " & vbTab & """Property Name"" is system language dependent." _
  64. 	       & vbCrLf & vbCrLf _
  65. 	       & "Written by Rob van der Woude" _
  66. 	       & vbCrLf _
  67. 	       & "http://www.robvanderwoude.com"
  68. 	WScript.Echo strMsg
  69. 	WScript.Quit 1
  70. End Sub
  71.  

page last modified: 2024-04-16; loaded in 0.0088 seconds