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

User avatar
van Dusen
Power Member
Power Member
Posts: 684
Joined: 2004-09-16, 19:30 UTC
Location: Sinzig (Rhein), Germany

CountExt.vbs (Update)

Post by *van Dusen »

The updated version of CountExt.vbs supports DOS patterns and regular expressions. A simple configuration tool can be downloaded here:

http://rapidshare.com/files/133429007/ScriptWDX_CountExt.zip.html

(the AU3 source code and the VBS script are included)

Code: Select all

'*** CountExts.vbs, V1.2 (inline configuration, support for RegExp's / DOS patterns), 29.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 fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim vExts(9)
Dim vRecurse, vDistinct, vProperty

'*** 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" | "Exists"
vProperty = "NumAbs"

'vSizeUnit: Einheit, nur relevant für vProperty = "SizeAbs": "bkMG" = Dynamisch; "b" = Bytes; "k" = KiB; "M" = MiB; "G" = GiB; ...; "E" = EiB
vSizeUnit = "bkMG"

'vExtsPatternType: "Ext" | "DOS" | "RegEx"
vExtsPatternType = "Ext"

vExts(1) = ":7Z:ACE:CAB:CATALOG:DISKDIR:GZ:GZIP:JAR:PJG:RAR:SBC:SQX:TAR:TGZ:UC2:UHA:UUE:XXE:Z:ZIP:" 'Archive
vExts(2) = ":ANI:BMP:CR2:CUR:DIB:EMF:GIF:ICO:J2K:JP2:JPG:JPEG:PFI:PNG:PSD:PSP:TGA:TIF:TIFF:WMF:" 'Grafik
vExts(3) = ":AU:MID:MP3:OGG:WAV:WMA:" 'Audio
vExts(4) = ":AVI:FLC:FLI:MOV:MPEG:MPG:QTIF:SFW:SWF:WMV:" 'Videos
vExts(5) = ":DOC:DOT:MDB:MDE:MSG:POT:PPT:PST:RTF:VSD:XLS:XLT:" 'Office
vExts(6) = ":CHM:HLP:HTM:HTML:MHT:PDF:TXT:" 'Doku
vExts(7) = ":COM:DLL:EXE:WCX:WDX:WFX:WLX:" 'Executables
vExts(8) = ":AHK:AU3:BAT:JS:PIF:SH:SQL:TCS:VBS:" 'Scripte
vExts(9) = ":ALT:BAK:OLD:ORI:SIK:TIB:XLK:" 'Backup
'vExts(-) = ":TTF:TTC:OTF:FON:PFM:" 'Fonts

'*** Benutzerkonfigurierbarer Bereich - Ende ************************************

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

Dim vGroupsMatched
Dim vExtInGroup(9)
Dim vResult(9)
For vI = 0 To 9
	If vExtsPatternType = "DOS" Then
		vExts(vI) = Replace(vExts(vI), "^", "\^")
		vExts(vI) = Replace(vExts(vI), "$", "\$")
		vExts(vI) = Replace(vExts(vI), ".", "\.")
		vExts(vI) = Replace(vExts(vI), "+", "\+")
		vExts(vI) = Replace(vExts(vI), "(", "\(")
		vExts(vI) = Replace(vExts(vI), ")", "\)")
		vExts(vI) = Replace(vExts(vI), "[", "\[")
		vExts(vI) = Replace(vExts(vI), "]", "\]")
		vExts(vI) = Replace(vExts(vI), "{", "\{")
		vExts(vI) = Replace(vExts(vI), "}", "\}")
		vExts(vI) = Replace(vExts(vI), "?", ".")
		vExts(vI) = Replace(vExts(vI), "*", ".*")
	End If
	vResult(vI) = 0
	vExtInGroup(vI) = 0
	If vExts(vI) = "" Then vExtInGroup(vI) = 1
Next

Dim vFolder
Dim vFileCollection, vFile, vFileExt, vFileSize
Dim vSubFolderCollection, vSubFolder

Dim vPath
vPath = fso.GetAbsolutePathName(filename)

If vExtsPatternType <> "Ext" Then
	Dim vRegExpExts, vMatchExts, vMatchesExts
	Set vRegExpExts = New RegExp
	vRegExpExts.Pattern = "(.+?):"
	vRegExpExts.IgnoreCase = True
	vRegExpExts.Global = True
	
	Dim vRegExpFile
	Set vRegExpFile = New RegExp
	vRegExpFile.IgnoreCase = True
End If

If fso.FolderExists(filename) Then
	RecurseDir(vPath)
Else
	Set vFile = fso.GetFile(filename)
	If vExtsPatternType = "Ext" Then
		CheckExt(fso.GetExtensionName(filename))
	Else
		CheckPat()
	End If
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
'~~~

If vProperty = "Exists" Then
	vResult(0) = vCharIfResultIsZero
	For vI = 1 To 9
		If vResult(vI) = 0 Then
			vResult(vI) = vCharIfResultIsZero
		Else
			vResult(vI) = vExtInGroup(vI)
		End If		
	Next

End If
'~~~

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

For vI = 1 To 9
	If vExts(vI) = "" Then vResult(vI) = ""
Next

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
	For Each vFile In vFileCollection
		If vExtsPatternType = "Ext" Then
			CheckExt(fso.GetExtensionName(vFile))
		Else
			CheckPat()
		End If
	Next
	
	If vRecurse = 0 Or (vProperty = "Exists" And vGroupsMatched = 10) Then Exit Function
	
	Set vSubFolderCollection = vFolder.SubFolders
	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
			vExtInGroup(vI) = 1
			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
	
	vGroupsMatched = 0
	For vI = 0 To 9
		vGroupsMatched = vGroupsMatched + vExtInGroup(vI)
	Next
	If vProperty = "Exists" And vGroupsMatched = 10 Then Exit Function
	
	If vProperty = "SizeAbs" Or vProperty = "SizeRel" Then
		vResult(0) = vResult(0) + vFile.Size * vExtNotMatch
	Else
		vResult(0) = vResult(0) + vExtNotMatch
	End If
	
End Function
'~~~

Function CheckPat()
	vExtNotMatch = 1
	
	For vI = 1 To 9
		
		Set vMatchesExts = vRegExpExts.Execute(vExts(vI))
		For Each vMatchExts In vMatchesExts
			vRegExpFile.Pattern = Replace(vMatchExts.Value, ":", "")
			If vRegExpFile.Test(vFile.Name) Then
				vExtNotMatch = 0
				vExtInGroup(vI) = 1
				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 vExtNotMatch = 0 And vDistinct = 1 Then Exit For
		
	Next
	
	vGroupsMatched = 0
	For vI = 0 To 9
		vGroupsMatched = vGroupsMatched + vExtInGroup(vI)
	Next
	If vProperty = "Exists" And vGroupsMatched = 10 Then Exit Function
	
	If vProperty = "SizeAbs" Or vProperty = "SizeRel" Then
		vResult(0) = vResult(0) + vFile.Size * vExtNotMatch
	Else
		vResult(0) = vResult(0) + vExtNotMatch
	End If
	
End Function
'~~~
User avatar
chrizoo
Senior Member
Senior Member
Posts: 349
Joined: 2008-03-12, 02:42 UTC

Post by *chrizoo »

PyTyus wrote:Lev,

Thank you for this very useful plugin. I found it about a month ago and have been using it on a daily basis since.

I was particularly looking for some content plugin which would return the values from inside of a file and I could specify the search criteria myself. Even after extensive search in TC forum didn't find anything suitable except for Script Content Plugin.
Hi everyone and thanks Petr for sharing this wonderful code, that's exactly what I was looking for a long time!
  • Is this the actually the ONLY WAY to achieve this (i.e. to rename a file based on a string found inside the file) in TC ???
  • Do you have a clever idea to quickly modify the regexp pattern in your script so that it can be quicker integrated in the workflow when renaming different files ?
Thanks a lot
User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev »

(Wish) Content plugin property parameter - in this tread I described a method to pass a parameter to script via TC Column configuring.
User avatar
chrizoo
Senior Member
Senior Member
Posts: 349
Joined: 2008-03-12, 02:42 UTC

Post by *chrizoo »

Hi Lev, thanks for the info. I read through the linked thread and ... hm ... I have a vague idea what it is about, but I think everyone who posted there knows stuff about plugin development, whereas I have no clue...
I'll still read through it again and if I still don't get anything of it, maybe I'll ask you ...
but, just upfront: what's the bottomline? Is what you describe there only a suggestion for improvement or is there something inside the thread I can actually use myself already right now?

In the meanwhile something else: Your script searches for a string inside the file and passes it to the multi-rename-tool or custom columns. Can the script be modified somehow to work with directories also? I mean the script would search for a string within the filenames of the directory (maybe also in subdirs optionally) and also passes it to the MRT or columns. Wouldn't this be a good idea?
User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev »

The example of using AHK scripts with Script Content plugin - File Defragment
User avatar
Antonski
Junior Member
Junior Member
Posts: 15
Joined: 2007-11-13, 21:22 UTC
Location: Sofia, Bulgaria

Re: Mediainfo-Script

Post by *Antonski »

brotbuexe wrote: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.
Great!
It seems that's exactly what I need.
However I cannot obtain even one value. I've tried latest MediaInfo version, v0.7.12.
I've checked with WDX Guide, returned value is ft_nosuchfield.
Any idea?
Thanks in advance.

Edit: Sorry for disturbing you, I've managed to make it working.
Cheers.
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

A script to display the day of week in TC. To make it sortable, the standard is a DOW-number, followed by a two-letter text.
Result = "1_Mo" for a monday.
boAbbreviate = 0 gives back the full day names.
Result1/2/3/9 contain some alternative contents, whatever you prefer.

Backdraws in this version:
- it's not very fast this way
- some virus scanners may complain about the file system object to read the date infos
- dirs are not supported yet, only files

P.S.: There's a more efficient special plugin for this purpose, DateNames by Lefteous,
so this is probably only useful for experimental and educational use.

Code: Select all

' Script for Script Content Plugin,
' showing day of week for the modified file date
' (W) StatusQuo 2009

boAbbreviate = 1

Dim fs, f
Dim sDate, sDowNumOnly, sDowOnly, sDatePlusWeekDay, sTimeOnly, sDateOnly
Set fs = CreateObject("Scripting.FileSystemObject")
Set f  = fs.GetFile(filename)
sDate  = f.DateLastModified
If (Len(sDate) < 12) then		' "dd.mm.yy " / "dd.mm.yyyy "
	sTimeNullAdd = " 00:00:00"	' add time, if it's missing because of zero value
' Else
	' sTimeNullAdd = ""
End If
sDateStr = sDate & sTimeNullAdd

sDowOnly         = WeekDayName(WeekDay(sDate, vbMonday), boAbbreviate, vbMonday)
sDowNumOnly      =             WeekDay(sDate, vbMonday) & "_" & sDowOnly
sDatePlusWeekDay = sDateStr & ", " & sDowOnly
sTimeOnly        = Right(sDateStr, 8)
sDateOnly        = Left(sDateStr, Len(sDateStr) - 9)

content = sDowNumOnly      ' number + day-of-week only
content1= sDowOnly         ' day-of-week only
content2= sTimeOnly
content3= sDateOnly
content9= sDatePlusWeekDay ' date plus day-of-week

Set fs = Nothing
Set f = Nothing
sDate = 0
sDowNumOnly = 0
sDowOnly = 0
sDatePlusWeekDay = 0
sTimeOnly = 0
sDateOnly = 0
Example INI entry for it:

Code: Select all

[Script]
Section=WeekDay

[WeekDay]
Script=WeekDay.vbs
LongName=0
ParseDirs=0 
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
van Dusen
Power Member
Power Member
Posts: 684
Joined: 2004-09-16, 19:30 UTC
Location: Sinzig (Rhein), Germany

CheckEncoding.vbs

Post by *van Dusen »

The following script CheckEncoding.vbs detects the character encoding and the line ending character(s) of a file.

List of possible return values for column character encoding ([=script.Result1]):
  • Binary
  • ASCII
  • ANSI
  • Unicode: UTF-8
  • Unicode: UTF-8 BOM
  • Unicode: UTF-16 LE BOM
  • Unicode: UTF-16 BE BOM
  • Unicode: UTF-32 LE BOM
  • Unicode: UTF-32 BE BOM
List of possible return values for line endings ([=script.Result2]):
  • None
  • CRLF (Win)
  • LF (Unix)
  • CR (Mac)
In column [=script.Result] both results are concatenated


Due to performance reasons, the script checks only the first 1024 bytes of a file. This may cause inaccurate results. You can adjust the number of bytes checked by changing the line

Code: Select all

vFileContentIn = f.Read(1024)

Script <CheckEncoding.vbs>

Code: Select all

'*** CheckEncoding, van Dusen, 31.07.2009
'*** 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

'*** [=script.Result]  ===> Character Encoding  •  Line Endings
'*** [=script.Result1] ===> Character Encoding {ASCII|ANSI|Binary|Unicode: UTF-8|Unicode: UTF-8 BOM|Unicode: UTF-[16|32] [LE|BE] BOM}
'*** [=script.Result2] ===> Line Endings       {None|CRLF (Win)|LF (Unix)|CR (Mac)}

Dim oFSO, f
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set f = oFSO.OpenTextFile(filename, 1, False)
vFileContentIn = f.Read(1024)
'vFileContentIn = f.ReadAll
f.Close
Set f = Nothing
Set oFSO = Nothing

	
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Check Character Encoding
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vEncoding = "?"

'Bytefolgen der BOM in verschiedenen Zeichenkodierungen
'Kodierung              Bytefolge 
'UTF-8                  EF BB BF    (239 187 191)
'UTF-16 Big Endian      FE FF       (254 255)
'UTF-16 Little Endian   FF FE       (255 254)
'UTF-32 Big Endian      00 00 FE FF (000 000 254 255)
'UTF-32 Little Endian   FF FE 00 00 (255 254 000 000)

vBOM = Left(vFileContentIn, 2)
If vBOM = Chr(&HFF) & Chr(&HFE) Then vEncoding = "Unicode: UTF-16 LE BOM"
If vBOM = Chr(&HFE) & Chr(&HFF) Then vEncoding = "Unicode: UTF-16 BE BOM"

vBOM = Left(vFileContentIn, 3)
If vBOM = Chr(&HEF) & Chr(&HBB) & Chr(&HBF) Then vEncoding = "Unicode: UTF-8 BOM"

vBOM = Left(vFileContentIn, 4)
If vBOM = Chr(&H00) & Chr(&H00) & Chr(&HFE) & Chr(&HFF) Then vEncoding = "Unicode: UTF-32 BE BOM"
If vBOM = Chr(&HFF) & Chr(&HFE) & Chr(&H00) & Chr(&H00) Then vEncoding = "Unicode: UTF-32 LE BOM"


If vEncoding = "?" Then
	Dim vRegExp
	Set vRegExp = New RegExp
	vRegExp.IgnoreCase = False
	vRegExp.Global = True
	
	vRegExp.Pattern = "[\x09-\x0D\x20-\x7E]"
	vFileContentOt = vRegExp.Replace(vFileContentIn, "")
	If vFileContentOt = "" Then
		vEncoding = "ASCII"
		
	Else
		vEncoding = "Unicode: UTF-8"
		For vI = 1 To Len(vFileContentIn)
			
			vAsc = Asc(Mid(vFileContentIn, vI, 1))
			vSubseqBytes = 0
			
			'[\x00-\x7F] = 0xxxxxxx
			If vAsc >= &H00 And vAsc <= &H7F Then
				vSubseqBytes = 0
			'[\xC0-\xDF][\x80-\xBF] = 110xxxxx 10xxxxxx
			ElseIf vAsc >= &HC0 And vAsc <= &HDF Then
				vSubseqBytes = 1
			'[\xE0-\xEF][\x80-\xBF][\x80-\xBF] = 1110xxxx 10xxxxxx 10xxxxxx
			ElseIf vAsc >= &HE0 And vAsc <= &HEF Then
				vSubseqBytes = 2
			'[\xF0-\xF7][\x80-\xBF][\x80-\xBF][\x80-\xBF] = 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
			ElseIf vAsc >= &HF0 And vAsc <= &HF7 Then
				vSubseqBytes = 3
			Else
				vSubseqBytes = 0
				vEncoding = "?"
			End If
			
			If vI + vSubseqBytes > Len(vFileContentIn) Then Exit For
			
			For vJ = 1 To vSubseqBytes
				vI = vI + 1
				vAsc = Asc(Mid(vFileContentIn, vI, 1))
				If vAsc < &H80 Or vAsc > &HBF Then
					vEncoding = "?"
					Exit For
				End If
			Next
			
			If vEncoding = "?" Then Exit For
			
		Next
		
		If vEncoding = "?" Then
			vRegExp.Pattern = "[\x00-\x08\x0E-\x1F\x7F]" 'Control Chars
			vFileContentOt = vRegExp.Replace(vFileContentIn, "")
			If vFileContentIn = vFileContentOt Then
				vEncoding = "ANSI"
			Else
				vEncoding = "Binary"
			End If
		End If
		
	End If
	
End If

content1 = vEncoding


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Check Line Endings
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vLineEndings = ""
vCR = ""
vLF = ""

Select Case vEncoding
	Case "ASCII", "ANSI", "Unicode: UTF-8", "Unicode: UTF-8 BOM" '0D 0A
		vCR = Chr(13)
		vLF = Chr(10)
	Case "Unicode: UTF-16 BE BOM" '00 0D 00 0A
		vCR = Chr(00) & Chr(13)
		vLF = Chr(00) & Chr(10)
	Case "Unicode: UTF-16 LE BOM" '0D 00 0A 00
		vCR = Chr(13) & Chr(00)
		vLF = Chr(10) & Chr(00)
End Select
vCRLF = vCR & vLF

If vCRLF <> "" Then
	vLineEndings = "None"
	If InStr(1, vFileContentIn, vCRLF) > 0 Then
		vLineEndings = "CRLF (Win)"
	Else
		If InStr(1, vFileContentIn, vCR) > 0 Then vLineEndings = "CR (Mac)"
		If InStr(1, vFileContentIn, vLF) > 0 Then vLineEndings = "LF (Unix)"
	End If
End If

content2 = vLineEndings


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Concatenation and Output Encoding & Line Endings
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

content = vEncoding
If vLineEndings <> "" Then
	content = content & "  " & ChrW(&H2022) & "  " & vLineEndings
End If

INI <script.ini> for the script

Code: Select all

[Script]
Section=CheckEncoding

[CheckEncoding]
Script=CheckEncoding.vbs
LongName=1
ParseDirs=0

Language file <script.lng> for the script (optional!)

Code: Select all

[xxx]
Result=CharacterEncodingAndLineEndings
Result1=CharacterEncoding
Result2=LineEndings
Change the section name [xxx] to the language you are using in TC, [deu] for german, for instance.


If you have already other scripts in use, you could register a copy of the plugin script.wdx as script_checkencoding.wdx. In this case you must name your optional language file accordingly (script_checkencoding.lng).
stifani
Junior Member
Junior Member
Posts: 19
Joined: 2004-05-13, 02:32 UTC

Post by *stifani »

hello,

i just installed this plugin in total commander 7.55a,
but i can't get to work...

anyone can explain how to configure pls? :)

stif
eschamp
Junior Member
Junior Member
Posts: 14
Joined: 2004-10-30, 16:00 UTC

Need a script

Post by *eschamp »

I'm not a programmer but I have a problem that should be fairly easy to solve with this plugin.

I have a bunch of files with names like text123.txt that I would like to
change to something more meaningful.

Fortunately, each of them has the desired filename as their first line.
For example, the file text197.txt consists of these three lines:

HD TESTERS

See manufacturers' website

I would like to change the name to HD TESTERS.txt or HD_TESTERS.txt (all lowercase is OK, too)

Can anyone help me? Thanks.
User avatar
Peter
Power Member
Power Member
Posts: 2064
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

Here is a German thread with some code which handles the same problem:
Multi-rename with file-content
http://ghisler.ch/board/viewtopic.php?t=11518

HTH.

Peter
TC 10.xx / #266191
Win 10 x64
eschamp
Junior Member
Junior Member
Posts: 14
Joined: 2004-10-30, 16:00 UTC

Post by *eschamp »

Peter wrote:Here is a German thread with some code which handles the same problem:
Multi-rename with file-content
http://ghisler.ch/board/viewtopic.php?t=11518

HTH.

Peter
It would probably help a lot if I could read German! Do you have a script that does what I want? "Danke". :-)
User avatar
nsp
Power Member
Power Member
Posts: 1805
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Post by *nsp »

@eschamp

If you want to do it using a batch (file by file) you can use this script :

Code: Select all

@echo off
:begin
if "a%1" == "a" goto end
for /f "usebackq delims=" %%a in ( %1 ) DO (
  set fname="%%a.%2"
  goto ren
)
:ren
ren %1 %fname%
shift
goto begin
:end
you can make a button, parameter are all selected file names "%P%S".
It only works with ansi file.

If you want to do it with script content plugin, you have to install additional script that capture first line of file and use the content field in multirename tool.
Simple Script (firstline.vbs):

Code: Select all

Set fso = CreateObject("Scripting.FileSystemObject")
Set oTextStream = fso.OpenTextFile(filename)

If not oTextStream.AtEndOfStream Then
  content = oTextStream.ReadLine
End If

oTextStream.Close
You can fine all infos in previous post on how to install and use script content plugin
zuccadoc
Junior Member
Junior Member
Posts: 20
Joined: 2008-03-14, 08:40 UTC

Request: convert to x64!

Post by *zuccadoc »

Wake up. Neo...

:D

Hey Lev,
check this out:

http://www.ghisler.ch/board/viewtopic.php?t=30891

...and the entire world needs a 64x version of your wonderful plugin!
I'm sure you can make the miracle again.

If Lev can not solve the problem (sometime meteorites fall from the sky), does anybody know anything like this but x64?

@Rest of the world: please support this guy for his wonderful job!

PS: My next post here will be in the 2023, for the x128 version.

Cheers
I follow the truth.
Psychedelic
Junior Member
Junior Member
Posts: 20
Joined: 2011-10-30, 15:35 UTC

Post by *Psychedelic »

Hi all.

Here we are:

[wdx] WinScript Advanced Content Plugin (x86\x64)

http://ghisler.ch/board/viewtopic.php?t=44032

Features:

* Multiple columns per one script (up to 21);
* Unlimited number of simultaneously working scripts in one group of columns;
* Custom title name for any column;
* VBS and JS scripts;
* Stable and fast
* Fully compatible with scripts that was created for script_wdx plugin (By Lev Freidin), you do not need to fix them.

Image: http://img10.lostpic.net/2016/05/13/c8a787207256710b7dffcf3f369fd73e.png
Post Reply