Jump to content


Remove lines in text file that end in ".zip"


  • Please log in to reply
4 replies to this topic

#1 mapleboy

mapleboy
  • Guests

Posted 19 July 2012 - 04:17 AM

I have a text file that has file names on each line and I would like to use autohotkey to clean up the file and remove every line that ends in ".zip". How would I go about doing this?

#2 MasterFocus

MasterFocus
  • Moderators
  • 4127 posts

Posted 19 July 2012 - 04:36 AM

You may use Loop [read file contents] and InStr().

If you're not familiar with the syntax, start here.

#3 Alpha Bravo

Alpha Bravo
  • Members
  • 863 posts

Posted 19 July 2012 - 01:23 PM

FileRead, var, test.txt

FileDelete, test.txt

FileAppend, % RegExReplace(var, "`am).*\.zip\r\n"), test.txt


#4 sinkfaze

sinkfaze
  • Moderators
  • 6087 posts

Posted 19 July 2012 - 11:34 PM

Slight adjustment to that:

FileRead, var, test.txt
FileDelete, test.txt
FileAppend, % RegExReplace(var, "`am).*\.zip[color=#FF0000](?:\v+)?[/color]"), test.txt	[color=#00BF00]; vertical whitespace should match optionally in the event that a ".zip" line is the last line in the file[/color]


#5 flyingDman

flyingDman
  • Members
  • 1072 posts

Posted 20 July 2012 - 02:15 AM

Or using Hugof's TF (<!-- m -->http://www.autohotke...ugov/tf-lib.htm<!-- m -->)
TF_Replace("File.txt",".zip")