WildEdit : Command line interface

Ideas for new features

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
objectsmith
Posts: 1
Joined: Mon Sep 22, 2008 12:49 pm
Location: London, UK

WildEdit : Command line interface

Post by objectsmith »

would be great if it was possible to use wildedit in batch mode with no gui. Calling from the command line with parameters or passing a file containing the gui control equivalents. I have a weekly task which I could then setup as a schedule task. thanks...
User avatar
kengrubb
Posts: 324
Joined: Thu Dec 11, 2003 5:23 pm
Location: Olympia, WA, USA

Post by kengrubb »

It's not exactly what you're wanting, but I've recently ventured out into the world of AutoIt--a totally free scripting language.

http://www.autoitscript.com/autoit3/index.shtml

I started playing around with an automation script for WE2. It looks like it's easily doable, but it's a little oogie because you'll have to manipulate the config2.xml file.

You'll want to get a basic understanding of AutoIt, but here is a script I coded up. It doesn't actually execute and make changes, but I think it does a pretty good job of showing you what's possible.
; Opens WildEdit
; =====================================================================

Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declare

Dim $FilePath = @UserProfileDir & "\Application Data\Helios\WildEdit\config2.xml"
Dim $HoldPath = @UserProfileDir & "\Application Data\Helios\WildEdit\config2a.xml"
Dim $File, $HoldFile

If Not FileExists($FilePath) Then Exit

$File = FileRead($FilePath)

; Checkboxes are stored in config2.xml in 'modes' (0 is unchecked, 1 is checked)
; 1st byte - "." matches null characters
; 2nd byte - "." matches end of line characters
; 3rd byte - Literal replacement
; 4th byte - Search subfolders
; 5th byte - Match case
; 6th byte - Match whole words
; 7th byte - Regular expression

$File = StringRegExpReplace($File, '<value name="modes" type="bitset">[0-9]{7}</value>', '<value name="modes" type="bitset">0000000</value>')

$HoldFile = FileOpen($HoldPath, 2)
FileWrite($HoldFile, $File)
FileClose($HoldFile)
FileMove($HoldPath, $FilePath, 1)

Run("C:\Program Files\WildEdit\WildEdit.exe", "C:\Program Files\WildEdit", @SW_MAXIMIZE)
WinWaitActive("WildEdit", "")

; ^(.{4})(.*)\r\n\1
Dim $SearchFor = '^1{^}(.{{}4{}})(.*)\r\n\1'
; $1$2
Dim $ReplaceWith = '$1$2'
Dim $Include = 'Text*.txt'
Dim $Exclude = 'Text336.txt'

Send('^1' & $SearchFor & '{TAB 6}' & $ReplaceWith & '{TAB 2}' & $Include & '{TAB}' & $Exclude)
(2[Bb]|[^2].|.[^Bb])

That is the question.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

If you don't need a GUI, you don't need a GUI application.

There are many ways of doing this on the command line, using any of many scripting languages.

For example, if you happen to use Perl, this one-line command will replace this with that everywhere in the given input file, saving the original with the extension .bak:

perl -i.bak -p -e "s/this/that/g" input.txt

For fancier tasks it's better to create a script and call that. There's no limit to what you can do.
Post Reply