Automate opening file running macro, closing file and repeat

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
tstrobel
Posts: 1
Joined: Sat Dec 15, 2007 7:58 pm

Automate opening file running macro, closing file and repeat

Post by tstrobel »

I have created a macro to search for a string, mark the line, and then delete the line. This works fine. But I have a list of 300 files I want to run this macro on, and don't know how to automate this macro. I need to open the first file on the list run the macro, close the file, then open the next file on the list, run the macro, and close the file and repeat for all 300 files on the list. I have tried the macro, but I am unable to specify a variable for the file name using the list of file name.

Any suggestions, as I want to save some time, as I need to run this macro on 600 files, that are 300MB each.
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

To do that in a single file you don't need a macro; you can do it with a simple regular expression search and replace:
Find what: .*string to match.*\n
Replace with: [nothing]

[X] Regular expression

Replace All
I'm not sure how best to get TextPad to do this to 300 (or 600) files.

But why use a GUI editor for this job? You're not going to look at all those files. There are several ways to do this with a one-liner on the Windows command line. For example, using sed (Google sed windows):
sed "/string to match/d" old_file > new_file
Post Reply