0

I have a list of links like this

http://mysite.com/wp-content/uploads/dogs-24x100.png
http://mysite.com/wp-content/uploads/dogs-640x2648.png
http://mysite.com/wp-content/uploads/dogs-72x300.png
http://mysite.com/wp-content/uploads/dogs-large.png
http://mysite.com/wp-content/uploads/dogs-medium.png
http://mysite.com/wp-content/uploads/dogs-small.png
http://mysite.com/wp-content/uploads/dogs.png
http://mysite.com/wp-content/uploads/cats-24x100.png
http://mysite.com/wp-content/uploads/cats-640x2648.png
http://mysite.com/wp-content/uploads/cats-72x300.png
http://mysite.com/wp-content/uploads/cats-large.png
http://mysite.com/wp-content/uploads/cats-medium.png
http://mysite.com/wp-content/uploads/cats-small.png
http://mysite.com/wp-content/uploads/cats.png

How do I delete the lines which have -large , -medium , -small , and end with -numberxnumber ? Platform - Windows 7 . Notepad++ and Sublime Text 2 installed .

2 Answers 2

1

If you will be doing it regularly, get hold of grep.exe, ported from Unix, then create a batch file containing:

grep <"%1" -v -E -e "-large|-medium|-small|-24x100|-72x300|-640x2048" >"%1.pruned

Make sure that the grep port supports -E. If not you will need a succession of calls:

grep <"%1" -v -e "-large" | grep -v -e "-medium" | grep ...

The -e option is needed because all the search strings start with -.

11
  • Is this the one ? wingrep.com
    – Renuka
    Commented Oct 27, 2014 at 13:13
  • I was thinking of a command-line port, such as in UnxUpdates.zip from the GNU Utilities. You may be able to use a GUI version, but not in a batch file.
    – AFH
    Commented Oct 27, 2014 at 13:41
  • How to use it ? I have over 50 files I need to edit . Your command has no "filename" in it .I downloaded UnxUpdates.zip . grep.exe closes when I open it . Do I have to add it in environmental variables ?
    – Renuka
    Commented Oct 27, 2014 at 13:45
  • You need to run it from cmd, when it displays Usage: grep OPTION]... PATTERN [FILE]... / Try 'grep --help' for more information. My command should be saved to a batch file, such as prune.cmd: %1 refers to a file name you pass as a parameter, as in prune "File 1". The file with the deleted entries will be "File 1.pruned". Once you are confident that it is working as you expect you can replace the original file by adding del "%1" and ren "%1.pruned" "%1" to the batch file
    – AFH
    Commented Oct 27, 2014 at 14:12
  • Finally, if you have a unique name pattern or extension for the files you need to process, you can process all the files in a single command, such as: for %f in (Pattern*.extn) do call prune "%f"
    – AFH
    Commented Oct 27, 2014 at 14:21
0

I've always had excel open on my desktop so use that alot.

Open the list in excel, filter on the column, then filter out the words that contain what you don't want. copy and paste the list to a new sheet and save

1
  • 1
    The tags are "regex" and "text-editor"
    – Prasanna
    Commented Oct 26, 2014 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .