Jump to content
Macro Express Forums

Find a symbol in each line of an open .txt file and delete it and preceding


Recommended Posts

I've got a macro set up for TextPad to find a text string using "Find in Files" and then save the search results. What I need is to clean up the labeling that TextPad inserts (as a reference to the files where the strings were found), leaving me with just the text I searched for. In the end I'll be importing the text into another program, so that's why I need the specific formatting.


What I'm trying to figure out for the moment is how to get a macro to search each line of text for a colon (":") and then delete it and everything preceding it on that line, then repeat till the last line of the text file.


Any suggestions? Or improvements on the overall scheme?

Link to comment
Share on other sites

It looks like you should be able to do this in 5 steps.


Text File Begin Process: "sample.txt"

Variable Set Integer %N1% from Position of Text in Variable %T1%

Variable Modify String: Delete Part of %T1%

Variable Modify String: Append %T1% to Text File

Text File End Process


Step 1 reads the first line of your text file and saves to T1.

Step 2 finds the position of the : character in the text string and saves it to N1

Step 3 deletes part of the text string - start at position one and delete N1 number of characters

Step 4 saves the new smaller string to a new text file. Select the Add Trailing CR/LF option.

Step 5 closes the loop and repeats the process for the next line in the text file.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...