Script Content Plugin

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

Moderators: sheep, Hacker, Stefan2, white

User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Script Content Plugin

Post by *Lev » 2005-09-25, 12:12 UTC

Script Content Plugin initial alfa.
Just an announcement.
I think interesting scripts can be posted here for sharing.

User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz » 2005-09-25, 13:29 UTC

Nice, i just tried it, thanks! Whenever I have new scripts, i will post them here!
I switched to Linux, bye and thanks for all the fish!

User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz » 2005-09-27, 20:31 UTC

Ok, first try. Here is a [face=courier]DiskDirSize.vbs[/face] script.

Code: Select all

'DiskDirSize.vbs by SanskritFritz

'Script for Script Content Plugin
'(c)Lev Freidin, 2005
'http://www.totalcmd.net/plugring/script_wdx.html
'http://wincmd.ru/plugring/script_wdx.html
'
'This script shows the virtual size of a DiskDir file,
'i.e. the size of the files listed therein.
'Warning: it gives a false result on DiskDir Extended files
'(because directories are assumed to have a size of 0)!

content = ""

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

Select Case sExt

case "lst", "ddr" ' lst is the suggested extension, I personally use ddr
	Set oTextStream = fso.OpenTextFile( filename )
	content = 0
	Do Until oTextStream.AtEndOfStream
		sLine = oTextStream.ReadLine
		aFields = Split( sLine, "	" ) ' <- This is a TAB character!
		if Ubound( aFields ) > 1 then
			content = content + aFields(1)
		end if
	Loop
	content = FormatNumber( content, 0, -2, -2, -2 )
	oTextStream.Close

End Select

Set fso = nothing
Set oTextStream = nothing
I switched to Linux, bye and thanks for all the fish!

User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev » 2005-09-28, 12:18 UTC

Thanks for your script!

Silent update - I've added "exe-files-up" script example to the plugin, without plugin itself changes

User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz » 2005-09-28, 12:42 UTC

Thanks, nice idea! IIRC this was requested many times here in the forum.
Hmm, time to open a wiki section for these scripts?
I switched to Linux, bye and thanks for all the fish!

User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev » 2005-09-28, 13:07 UTC

SanskritFritz wrote:Hmm, time to open a wiki section for these scripts?
I don't know, the plugin is rather buggy yet...
and I'm planning some changes like several columns, js-scripts support and so on

User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz » 2005-09-28, 13:10 UTC

Ok, even though it works like charm for me here.
I meant only the scripts, they will not have to be changed do they? Oh, now I just see, multi columns will change them, ok.
I switched to Linux, bye and thanks for all the fish!

User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev » 2005-09-28, 14:04 UTC

It is impossible to use subroutines in scripts currently, it need's to be repaired. It can cause some changes in scripts too.

User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz » 2005-09-28, 18:13 UTC

I hope you will have the time and motivation to continue with this awesome plugin! Thanks again for it!
I switched to Linux, bye and thanks for all the fish!

ricobautsch
Member
Member
Posts: 103
Joined: 2005-06-21, 00:42 UTC

Post by *ricobautsch » 2005-10-05, 00:24 UTC

Very nice and usefull plugin :D
My personal most wanted features are support for Subs/Functions in the code, and support of more than one column per script.
But also without this features... very usefull.

Following a little script, which can be usefull to search for files with a specified signature (first bytes in the file).

Code: Select all

'signatur.vbs by ricobautsch

'Script for Script Content Plugin (c)Lev Freidin, 2005 
'http://www.totalcmd.net/plugring/script_wdx.html 
'http://wincmd.ru/plugring/script_wdx.html 
' 
'This script returns the first 10 bytes in the file as text or hex-representation.
'Could be usefull for example to search for files with a specified signatur

const bHex = True
const nCharCnt = 10

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

If not oTextStream.AtEndOfStream Then
  content_str = oTextStream.Read(nCharCnt)
  
  If bHex Then
    For i=1 To Len(content_str) 
      If content <> "" Then
        content = content & " "
      End If
      
      hex_value = Hex(Asc(Mid(content_str,i,1)))
      
      content = content & string(2 - len(hex_value), "0")
      content = content & hex_value
    Next
  Else
    content = content_str
  End If
End If

oTextStream.Close

User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz » 2005-10-05, 12:25 UTC

2ricobautsch
Nice idea!
I switched to Linux, bye and thanks for all the fish!

User avatar
Lev
Junior Member
Junior Member
Posts: 82
Joined: 2004-12-14, 13:08 UTC

Post by *Lev » 2005-10-05, 17:33 UTC

2ricobautsch
Thanks for interesting script
------------
I've added js support to plugin, but since I don't use js myself, the example is very simple

support for Subs/Functions in the code, and support of more than one column per script are still in work

User avatar
Peter
Power Member
Power Member
Posts: 1916
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz
Contact:

Looking for help for addzeros.vbs

Post by *Peter » 2005-11-04, 21:14 UTC

Hello

I found the script addzeros.vbs in the download file, and I'm asking for a little help.

Here is the original code:

Code: Select all

'Script for Script Content Plugin
'(c)Lev Freidin, 2005
'http://www.totalcmd.net/plugring/script_wdx.html
'http://wincmd.ru/plugring/script_wdx.html

'Add Zeros to filenames for better sorting
'file1.txt -> file001.txt
'file11.txt -> file011.txt
'file111.txt -> file111.txt 

set re=new regexp

content=filename

re.Pattern="(\D)(\d\.)"
b="$100$2"
If re.test(filename) then content = re.Replace(filename,b)

re.Pattern="(\D)(\d{2}\.)"
b="$10$2"
If re.test(filename) then content = re.Replace(filename,b)

This code works only for files which beginns with a letter: it works fine for x1.txt, x12.txt, x111.txt ...; but it doesnot work for 1.txt, 11.txt, 12.txt ...

What is the correct code do set a filename (consisting of numbers) to a triple digit number:
  • 1.txt -> 001.txt
    02.txt -> 002.txt
    11.txt -> 011.txt
    111.txt -> 111.txt
Thanks in advance

Peter
TC 9.22a / #266191
Win 7 x64 / Win 10 x64

User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Re: Looking for help for addzeros.vbs

Post by *Sheepdog » 2005-11-04, 22:15 UTC

Peter wrote:

Code: Select all

'Script for Script Content Plugin
'(c)Lev Freidin, 2005
'http://www.totalcmd.net/plugring/script_wdx.html
'http://wincmd.ru/plugring/script_wdx.html

'Add Zeros to filenames for better sorting
'file1.txt -> file001.txt
'file11.txt -> file011.txt
'file111.txt -> file111.txt 

set re=new regexp

content=filename

re.Pattern="(.*)(\d\.)"
b="$100$2"
If re.test(filename) then content = re.Replace(filename,b)

re.Pattern="(.*)(\d{2}\.)"
b="$10$2"
If re.test(filename) then content = re.Replace(filename,b)

Hello Peter,

I have not installed the plugin thus I cannot test the script. But deducing from the RegEx help in TC I would say you'll have to replace the \D (which means 'no number') with .* (any char zero or more occurances). I changed the script that way I think it should work as you asked for. But I haven't tried so please be careful.

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams

User avatar
Peter
Power Member
Power Member
Posts: 1916
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz
Contact:

Post by *Peter » 2005-11-05, 08:10 UTC

Thanks

I will test it on Monday.

Peter
TC 9.22a / #266191
Win 7 x64 / Win 10 x64

Post Reply