Script Content Plugin

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

Hi,

I wrote a short script to give back the current date/time for using in MRT.
After some testing a user found out that it fails on directories, while it works OK with files:
http://ghisler.ch/board/viewtopic.php?p=147183#147183

This was reported for Vista 64bit and XP 32bit, I can confirm this for W2k SP4 (32bit).
It doesn't seem to matter what is in the script, as even "content=1" gives back an error in MRT on directories, while working OK on files:
Screenshot with "content=1" (tmp2 is a dir, 1!.out is a file)

Does somebody know how to get the plugin to work also for MRT-renaming directories?

Thanks in advance...
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev »

Did you set ParseDirs key? Like this:

Code: Select all

[Script]
Section=date
[date]
Script=date.vbs
ParseDirs=1
zuccadoc
Junior Member
Junior Member
Posts: 20
Joined: 2008-03-14, 08:40 UTC

Post by *zuccadoc »

Wow, now it works.

Thanks Lev!
I follow the truth.
User avatar
tbeu
Power Member
Power Member
Posts: 1336
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

TrID with Script Content plugin 0.2.0.0

Post by *tbeu »

wdx_TrID.js does no longer work with Script WDX 0.2.0.0.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

Lev wrote:Did you set ParseDirs key?
Great, after adding this my Now.vbs works. Thanks a lot.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev »

wdx_TrID.js does no longer work with Script WDX 0.2.0.0.
Yes, unfortunately I've broken support for js scripts and mentioned it somewhere in the readme file or on plugins page. You can use older versions of a plugin, untill I repair it.
User avatar
tbeu
Power Member
Power Member
Posts: 1336
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

OK! I put old version back online: script_wdx_0.1.0.1.rar
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev »

One more founding - I've forgotten about Case sensitivity of js, since I don't work with it.
You can try to rename 'content' to 'Content' in wdx_TrID.js to make it work with Script WDX 0.2.0.0.
other vars should be Content1, Content2 etc.
brotbuexe
Junior Member
Junior Member
Posts: 12
Joined: 2008-05-02, 17:23 UTC

Mediainfo-Script

Post by *brotbuexe »

Hi there,

I've made a quick and dirty Script to show some infos with the help of MediaInfo mediainfo.sourceforge dot net/en. The script uses the dll-Version mediainfo.sourceforge dot net/en/Download.

brotbuexe dot de/pics/mediainfo.png

Code: Select all

' quick and dirty Mediainfo Script for Totalcommander ScriptContent Plugin
' uses the Dll from mediainfo.sourceforge dot net
' 
' You have to register the Active-X-Control-Addon-Dll included in the Zip 
' (MediaInfo_0.7.6.4_DLL_Win32.7z\Developpers\Contrib\ActiveX\Release\MediaInfoActiveX_Install.bat). 
'
' The Batch copies the mediainfo.dll and the MediaInfoActiveX.dll to the windows\system32 Folder.
'
' For me, the registration of the Active-X-Dll only worked after I downloaded and unzipped the 
' msvbvm50.dll (from dll-files dot com/dllindex/dll-files.shtml?msvbvm50 for example)
' into %windir%\system32 Folder.
'
' You can check the registration by running "regsvr32 %windir%\system32\MediaInfoActiveX.dll". It should say "...succedded".
'
' v1.0 by BrotBuexe - 2. May 2008 

Const MediaInfo_Stream_Video    	= 1
Const MediaInfo_Stream_Audio    	= 2
Const MediaInfo_Stream_Text     	= 3
Const MediaInfo_Info_Name 	 		= 0 
Const MediaInfo_Info_Text 			= 1

Set fso = CreateObject("Scripting.FileSystemObject")
sExt = lcase(fso.GetExtensionName(filename))

Select Case sExt

Case "mkv", "avi", "mov", "mp3", "wav", "ogg", "mp4", "divx", "wmv", "rm", "mpg", "vob", "m2ts", "ts"
  Set obj = createObject("MediaInfo.ActiveX")
  handle = obj.MediaInfo_New()
  obj.MediaInfo_Open handle, CStr(filename)
  
  ' Frames per Second
  content = obj.MediaInfo_Get(handle, MediaInfo_Stream_Video, 0, "FrameRate", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  ' Resolution
  content1 = obj.MediaInfo_Get(handle, MediaInfo_Stream_Video, 0, "Width", MediaInfo_Info_Text, MediaInfo_Info_Name)  & "x" & obj.MediaInfo_Get(handle, MediaInfo_Stream_Video, 0, "Height", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  ' VideoBitrate
  content2 = obj.MediaInfo_Get(handle, MediaInfo_Stream_Video, 0, "BitRate/String", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  ' VideoCodec
  content3 = obj.MediaInfo_Get(handle, MediaInfo_Stream_Video, 0, "Codec", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  ' PlayTime
  content4 = obj.MediaInfo_Get(handle, MediaInfo_Stream_Video, 0, "PlayTime/String2", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  ' Number of Audiostreams
  content5 = obj.MediaInfo_Get(handle, MediaInfo_Stream_Audio, 0, "StreamCount", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  ' AudioBitrate
  content6 = obj.MediaInfo_Get(handle, MediaInfo_Stream_Audio, 0, "BitRate/String", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  ' Channel
  content7 = obj.MediaInfo_Get(handle, MediaInfo_Stream_Audio, 0, "Channel(s)", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  ' Number of Subs
  content8 = obj.MediaInfo_Get(handle, MediaInfo_Stream_Text, 0, "StreamCount", MediaInfo_Info_Text, MediaInfo_Info_Name)
  
  
  obj.MediaInfo_Close handle
  obj.MediaInfo_Delete handle
End Select
I'm sure there is a better solution, I'm not a coder at all... :)

The CustomFields for wincmd.ini (under [CustomFields]):

Code: Select all

Widths3=210,30,-31,-42,-47,80,-40,-41,-46,-34,-30
Headers3=FPS\nRes\nV Bitrate\nV Codec\nPlaytime\nA Streams\nA Bitrate\nA Chans\n# Subs
Contents3=[=script.Result]\n[=script.Result1]\n[=script.Result2]\n[=script.Result3]\n[=script.Result4]\n[=script.Result5]\n[=script.Result6]\n[=script.Result7]\n[=script.Result8]
Options3=1279|1
Sometimes the plugin crashes with this brotbuexe dot de/pics/script.png

Sorry, I had to reformat all the links because this is my first post and this forum thinks i could be a spammer... :/
User avatar
Peter
Power Member
Power Member
Posts: 2064
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

van Dusen, 6. Nov. 2005 wrote:

Code: Select all

re.Pattern="((\D+)|^)(\d{1})(\D+|$)"
b="$100$3$4"
If re.test(filename) then content = re.Replace(filename,b)

re.Pattern="((\D+)|^)(\d{2})(\D+|$)"
b="$10$3$4"
If re.test(filename) then content = re.Replace(filename,b)
How can this code extended (or modified) to work with directory-names?

Peter
TC 10.xx / #266191
Win 10 x64
R.A.W.
Junior Member
Junior Member
Posts: 5
Joined: 2008-06-09, 11:36 UTC

Post by *R.A.W. »

Hi there,

I wrote a little script for me which might be interesting for other people, too. It's purpose is to use the text in the clipboard for the MRT.

Code: Select all

'Simple clipboard Script for Total Commander ScriptContent Plugin
' 
'It's meant to be used with the MRT (Multi-Rename Tool).
'It strips all characters which aren't allowed in a filename from the clipboard.
'
'If this doesn't work you have to review the IE security settings.
'v1.0 by Milan "R.A.W." Franzkowski - 09. May 2008

dim objhtm
set objhtm=createobject("htmlfile")  
content=objhtm.parentwindow.clipboarddata.getdata("text")  

content=Replace(content,"\","")
content=Replace(content,"/","")
content=Replace(content,":","")
content=Replace(content,"*","")
content=Replace(content,"?","")
content=Replace(content,"""","")
content=Replace(content,"<","")
content=Replace(content,">","")
content=Replace(content,"|","")

'wscript.echo content
- R.A.W.
User avatar
van Dusen
Power Member
Power Member
Posts: 684
Joined: 2004-09-16, 19:30 UTC
Location: Sinzig (Rhein), Germany

Post by *van Dusen »

Peter wrote:How can this code extended (or modified) to work with directory-names?
Add "ParseDirs=1" to your script.ini (section "[Defaults]" or section with settings for your addzeros.vbs)
User avatar
Peter
Power Member
Power Member
Posts: 2064
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

Thanks van Dusen

Peter
TC 10.xx / #266191
Win 10 x64
User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev »

Section [Defaults] - is a fake section which does nothing, it is created just for remembering default settings of keys, which can be skipped in the sections. Changing [Defaults] will only mislead you. These settings will still be:
LongName=1
ParseDirs=0 untill they are overset in sections.
It is safe to delete [Defaults] section from the Script.ini
User avatar
van Dusen
Power Member
Power Member
Posts: 684
Joined: 2004-09-16, 19:30 UTC
Location: Sinzig (Rhein), Germany

CountExt.vbs

Post by *van Dusen »

The script CountExt.vbs calculates the number or the size (both absolute or relative) of files in a directory (and optional recursivelly in all subfolders) for up to 9 groups of files by means of their extensions. You can use this script amongst others in the "Find Files" dialogue, tab "Plugins" (to find directories, which does not contain a specific file type / files of a specific group of file extensions, for instance).

Change the configuration according to your wishes by editing the "User configurable area" of the script.


Script <CountExt.vbs>

Code: Select all

'*** CountExts.vbs, V1.0, 12.07.2008, van Dusen
'*** Script for Script Content Plugin 0.2
'*** Lev Freidin (c) 2005-2008
'*** http://www.totalcmd.net/plugring/script_wdx.html
'*** http://wincmd.ru/plugring/script_wdx.html

Dim vExts(9)
Dim vRecurse, vDistinct, vProperty

'*** User configurable area           - Begin *************************************
'*** Benutzerkonfigurierbarer Bereich - Beginn ************************************

'vRecurse: 1 = Scan subfolders recursively;             0 = Do not scan subfolders
'vRecurse: 1 = Unterverzeichnisse rekursiv durchsuchen; 0 = Unterverzeichnisse nicht durchsuchen
	vRecurse = 1

'vDistinct: 1 = Count file only for first matching file group     ; 0 = Count file for each matching file group
'vDistinct: 1 = Datei nur für erste zutreffende Dateigruppe zählen; 0 = Datei für alle zutreffenden Dateigruppen zählen
	vDistinct = 1

'vCharIfResultIsZero: Character/String which is displayed, if no file matchs the particular file group (e.g. "0", "", "-")
'vCharIfResultIsZero: Zeichen/String, das/der angezeigt wird, wenn sich für die Dateigruppe keine Datei qualifiziert hat (z.B. "0", "", "-")
	vCharIfResultIsZero = "-"

'vProperty: "NumAbs" | "NumRel" | "SizeAbs" | "SizeRel"
	vProperty = "NumAbs"

'vSizeUnit: Unit, only relevant for vProperty = "SizeAbs":   "bkMG" = Dynamically; "b" = Bytes; "k" = KiB; "M" = MiB; "G" = GiB; ...; "E" = EiB
'vSizeUnit: Einheit, nur relevant für vProperty = "SizeAbs": "bkMG" = Dynamisch; "b" = Bytes; "k" = KiB; "M" = MiB; "G" = GiB; ...; "E" = EiB
	vSizeUnit = "bkMG"
	
'(1) Archives / Archive
	vExts(1) = ":7Z:ACE:CAB:CATALOG:DISKDIR:GZ:GZIP:JAR:PJG:RAR:SBC:SQX:TAR:TGZ:UC2:UHA:UUE:XXE:Z:ZIP:"
'(2) Grafics / Grafiken
	vExts(2) = ":ANI:BMP:CUR:DIB:EMF:GIF:ICO:J2K:JP2:JPG:JPEG:PFI:PNG:PSD:PSP:TGA:TIF:TIFF:WMF:"
'(3) Audio
	vExts(3) = ":AU:MID:MP3:OGG:WAV:WMA:"
'(4) Videos
	vExts(4) = ":AVI:FLC:FLI:MOV:MPEG:MPG:QTIF:SFW:SWF:WMV:"
'(5) Office
	vExts(5) = ":DOC:DOT:MDB:MDE:MSG:POT:PPT:PST:RTF:VSD:XLS:XLT:"
'(6) Docu / Doku
	vExts(6) = ":CHM:HLP:HTM:HTML:MHT:PDF:TXT:"
'(7) Executables
	vExts(7) = ":COM:DLL:EXE:WCX:WDX:WFX:WLX:"
'(8) Scripts / Scripte
	vExts(8) = ":AHK:AU3:BAT:JS:PIF:SH:SQL:TCS:VBS:"
'(9) Backups
	vExts(9) = ":ALT:BAK:OLD:ORI:SIK:TIB:XLK:"

'*** Benutzerkonfigurierbarer Bereich - Ende ************************************
'*** User configurable area           - End *************************************

'(0) Other / Sonstige
	vExts(0) = ""

Dim vResult(9)
For vI = 0 To 9
	vResult(vI) = 0
Next

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim vFolder
Dim vFileCollection, vFile, vFileExt, vFileSize
Dim vSubFolderCollection, vSubFolder
Dim vPath
vPath = fso.GetAbsolutePathName(filename)


If fso.FolderExists(filename) Then
	RecurseDir(vPath)
Else
	Set vFile = fso.GetFile(filename)
	CheckExt(fso.GetExtensionName(filename))
End If

'~~~
If vProperty = "NumRel" Or vProperty = "SizeRel" Then
	vTotal = 0
	For vI = 0 To 9
		vTotal = vTotal + vResult(vI)
	Next
	For vI = 0 To 9
		If vResult(vI) = 0 Then
			vResult(vI) = vCharIfResultIsZero
		Else
			vResult(vI) = FormatPercent(vResult(vI) / vTotal, 1, -2, -2, -2)
		End If
	Next
End If
'~~~
If vProperty = "SizeAbs" Then
	For vI = 0 To 9
		If vResult(vI) = 0 Then
			vResult(vI) = vCharIfResultIsZero
		Else
			'If vResult(vI) > 0 Then
				If vSizeUnit = "bkMG" Then
					vExp = Int(Log(vResult(vI)) / Log(1024))
				Else
					vExp = InStr(1, "bkMGTPE", vSizeUnit)-1
				End If
			'Else
			'	vExp = 0
			'End If

			vFract = 1
			If vExp = 0 Then vFract = 0
			vResult(vI) = FormatNumber(vResult(vI) / (1024^vExp), vFract, -2, -2, -2)

			'If vExp > 6 Then
			'	vResult(vI) = vResult(vI) & "×1024^" & vExp & " b"
			'Else
				vResult(vI) = vResult(vI) & " " & Mid("bkMGTPE", vExp+1, 1)
			'End If
		End If
	Next
End If
'~~~
If vProperty = "NumAbs" Then
	For vI = 0 To 9
		If vResult(vI) = 0 Then
			vResult(vI) = vCharIfResultIsZero
		Else
			vResult(vI) = FormatNumber(vResult(vI), 0, -2, -2, -2)
		End If
	Next
End If
'~~~

Set vSubFolderCollection = Nothing
Set vFileCollection = Nothing
Set vFolder = Nothing
Set vFile = Nothing
Set fso = Nothing

content  = vResult(0)
content1 = vResult(1)
content2 = vResult(2)
content3 = vResult(3)
content4 = vResult(4)
content5 = vResult(5)
content6 = vResult(6)
content7 = vResult(7)
content8 = vResult(8)
content9 = vResult(9)

'~~~
Function RecurseDir(vFolderName)
	
	Set vFolder = fso.GetFolder(vFolderName)
	Set vFileCollection = vFolder.Files
	Set vSubFolderCollection = vFolder.SubFolders
	
	For Each vFile In vFileCollection
		CheckExt(fso.GetExtensionName(vFile))
	Next
	
	If vRecurse = 0 Then Exit Function
	
	For Each vSubFolder In vSubFolderCollection
		vPath = vPath & "\" & vSubFolder.Name
		RecurseDir(vPath)
		vP = InStr(1, StrReverse(vPath), "\")
		If vP > 0 Then vPath = Left(vPath, Len(vPath) - vP)
	Next
	
End Function
'~~~

Function CheckExt(vFileExt)
	vExtNotMatch = 1
	
	For vI = 1 To 9
		If InStr(1, LCase(vExts(vI)), ":" & LCase(vFileExt) & ":") > 0 Then
			vExtNotMatch = 0
			If vProperty = "SizeAbs" Or vProperty = "SizeRel" Then
				vResult(vI) = vResult(vI) + vFile.Size
			Else
				vResult(vI) = vResult(vI) + 1
			End If
			If vDistinct = 1 Then Exit For
		End If
	Next
	
	If vProperty = "SizeAbs" Or vProperty = "SizeRel" Then
		vResult(0) = vResult(0) + vFile.Size * vExtNotMatch
	Else
		vResult(0) = vResult(0) + vExtNotMatch
	End If
End Function
'~~~

INI <script.ini> for the script

Code: Select all

[Script]
Section=CountExt

[CountExt]
Script=CountExt.vbs
LongName=1
ParseDirs=1

Custom column view (template for <wincmd.ini>)
Replace '#' with the actual reference number of your custom column view (here labelled as "CountExt").

Code: Select all

[CustomFields]
Titles=[...]|CountExt|[...]

Widths#=85,30,-55,-40,-35,-35,-35,-35,-35,-35,-35,-35,-35,-35
Options#=-1|1
Headers#=Size tot.\nNum. tot.\nOther\nArchive\nGrafic\nAudio\nVideo\nOffice\nDocu\nExec\nScript\nBackup
Contents#=[=dirsizecalc.Size (Background)]\n
[=dirsizecalc.File Count (Background)]\n
[=script.Result]\n
[=script.Result1]\n
[=script.Result2]\n
[=script.Result3]\n
[=script.Result4]\n
[=script.Result5]\n
[=script.Result6]\n
[=script.Result7]\n
[=script.Result8]\n
[=script.Result9]
Post Reply