Jump to content
vinnyMS

replace words with a two column word list

Recommended Posts

hi,

i need a script that can replace words in text files based on a two column ("before" column and "after" column) word list (.txt) separated by TAB

the list contains Chinese language words

for example:

@2m07_dfmain1    @ryog
@2m07_参加活动3    @pvex
@2m07_参加活动4    @kgyn
@2m07_参加活动5    @qxsp
@2m07_参加活动6    @wblf
@2m07_娲诲姩缁撴潫    @gupm
@2m07_寮€濮嬮濂?    @tkfk

 

 

 

Share this post


Link to post
Share on other sites

Use StringSplit or _FileReadToArray using @Tab as the delimiter should create an array, then loop through the array and use stringreplace.

Share this post


Link to post
Share on other sites

here is a script to start

#Region INCLUDE
#include <AVIConstants.au3>
#include <GuiConstantsEx.au3>
#include <TreeViewConstants.au3>
#EndRegion INCLUDE

#Region GUI
GUICreate("Replace words", 400, 350)
GUISetIcon(@SystemDir & "\notepad.exe", 0)
#EndRegion GUI

#Region PROGRESS
GUICtrlCreateProgress(10, 310, 300, 20)
GUICtrlSetTip(-1, '#Region PROGRES')
GUICtrlSetData(-1, 60)
GUICtrlCreateLabel("Progress:", 5, 82)
GUICtrlSetTip(-1, '#Region PROGRES - Label')
#EndRegion PROGRESS


#Region LIST VIEW
Local $idListView = GUICtrlCreateListView("Before|After|", 10, 45, 300, 250)
GUICtrlSetTip(-1, '#Region LIST VIEW')
GUICtrlCreateListViewItem("cat|dog", $idListView)
GUICtrlCreateListViewItem("tree|hair", $idListView)
GUICtrlCreateListViewItem("spoon|house", $idListView)
#EndRegion LIST VIEW


#Region INPUT
GUICtrlCreateInput("C:\", 10, 10, 300, 20)
GUICtrlSetTip(-1, '#Region INPUT')
#EndRegion INPUT

#Region BUTTON
GUICtrlCreateButton("Browse", 330, 10, 50, 20)
GUICtrlSetTip(-1, '#Region BUTTON')
#EndRegion BUTTON

#Region BUTTON
GUICtrlCreateButton("Import", 330, 45, 50, 20)
GUICtrlSetTip(-1, '#Region BUTTON')
#EndRegion BUTTON

#Region BUTTON
GUICtrlCreateButton("Replace", 330, 310, 50, 20)
GUICtrlSetTip(-1, '#Region BUTTON')
#EndRegion BUTTON

#Region GUI MESSAGE LOOP
GUISetState(@SW_SHOW)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

GUIDelete()
#EndRegion GUI MESSAGE LOOP

 

 

 

Capture3.PNG

Edited by vinnyMS

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...