Example automation script for list files with file version

This is a place for users to discuss Altap Salamander. Please feel free to ask, answer questions, and express your opinion. Please do not post problems, bug reports or feature requests here.
Marc van Beveren
Posts: 6
Joined: 31 Dec 2010, 13:33

Example automation script for list files with file version

Post by Marc van Beveren »

Hi,

I like to get a list of all EXE/DLL files in the selected folder with the file version. As AS doesn't support this right now, I was wondering if this could be accomplished with a automation script which then can be started with a shortcut key or button.

If someone could give me an example working script then that would be very appreciated!

Marc
User avatar
th.
Posts: 116
Joined: 04 Sep 2006, 23:09
Location: Germany

Re: Example automation script for list files with file versi

Post by th. »

Hi Marc,
Here's a modification of the "Make list" VBS example script for you.

Code: Select all

'
'	Make List (VBScript).vbs
'	Creates the CSV list from the selected items.
'
'	Sample Altap Salamander Automation Script.
'
'	www.manison.cz
'
'	file version column added th. 21.09.2012

Dim Items

' Pick the collection of items to make the list from.
If Salamander.SourcePanel.SelectedItems.Count = 0 Then
	If Salamander.MsgBox("No items are selected. Do you want to make list from all items in the panel?", 4, "Question") = 6 Then
   		Set Items = Salamander.SourcePanel.Items
	End If
Else
	Set Items = Salamander.SourcePanel.SelectedItems
End If

If VarType(Items) <> 0 Then ' vbEmpty
        Dim Fso, WshShell, ListName, Item, File

	Set Fso = CreateObject("Scripting.FileSystemObject")
	Set WshShell = CreateObject("WScript.Shell")

	' Open the target file.
	ListName = WshShell.ExpandEnvironmentStrings("%TEMP%\FileList.csv")
	Set File = Fso.CreateTextFile(ListName, True)

	' Write down the header.
	File.WriteLine("Name;Size;Date;Attributes;Version")

	' Iterate through the item collection and record info about each of them into the file.
	For Each Item In Items
		If Item.Name <> ".." Then
			File.WriteLine(Item.Name & ";" & Item.Size & ";" & Item.DateLastModified & ";" & Item.Attributes & ";" & fso.GetFileVersion(Item.Path))
		End If
	Next

	' Close the file.
	File.Close

	' Deselect all items that could be eventually selected.
	Salamander.SourcePanel.DeselectAll

	' Focus created file in the other panel.
	Salamander.TargetPanel.Path = ListName

	If Salamander.MsgBox("List " & ListName & " was successfully created. Do you want to open it now?", 4, "Finished") = 6 Then
		' Open newly created list in the associated application.
		WshShell.Run(ListName)
	End If
End If
User avatar
SvA
Posts: 483
Joined: 29 Mar 2006, 02:41
Location: DE

Re: Example automation script for list files with file versi

Post by SvA »

If there is a standard way to access the version resource through an ActiveX component, building the list should be straight forward. For how to process the selected or focused panel item(s) see the example scripts.
However, AS automation script does not provide any GUI element to present the list. I once made an attempt to overcome this limitation by using HTA (html, JScript based dynamic web page presented as a local application window); see SpecialFolders Automation Script for more information and source.
To present your list, AS's Database Viewer was a good choice, only there's no API way to launch it.
So you either need to just create a file containing the info for separate visitation or use an external viewer (e.g. Notepad.exe) to view your data. To do so, you can either use a file to buffer the data or use some automation (sending key strokes/windows messages or ActiveX). There are many examples for using IE automation from WSH scripts on the net.
Marc van Beveren
Posts: 6
Joined: 31 Dec 2010, 13:33

Re: Example automation script for list files with file versi

Post by Marc van Beveren »

th. wrote:Hi Marc,
Here's a modification of the "Make list" VBS example script for you.
Thx.
Post Reply