Reputation: 874
Please provide a generic syntax that can be used to scan any type of image string, where, all that has to be done is pass in the correct file type extension to get the match. A more ideal approach, though not required, would be a way to pass in more than one file extension type.
The following is generated when navigating to a file directory in a Google Chrome browser:
Name Size Date Modified
[parent directory]
BamboNature.jpg 40.0 kB 10/22/15, 2:42:00 PM
bjs1.jpg 80.7 kB 10/22/15, 3:04:55 PM
BroodyChick.jpg 55.2 kB 10/22/15, 2:42:16 PM
EarthsBest01.jpg 95.9 kB 10/22/15, 3:04:38 PM
HonestDiaper.jpg 42.5 kB 10/22/15, 2:42:29 PM
Huggies_1.jpg 44.3 kB 10/22/15, 3:04:28 PM
Huggies_2.jpg 46.7 kB 10/22/15, 3:04:02 PM
Luvs_2.jpg 53.0 kB 10/22/15, 2:01:07 PM
Luvs.jpg 49.6 kB 10/22/15, 3:03:48 PM
Munchkin.jpg 40.6 kB 10/22/15, 3:03:31 PM
Pampers.jpg 49.6 kB 10/22/15, 3:03:24 PM
Pampers02.jpg 40.2 kB 10/22/15, 3:03:15 PM
parents-choice-unscented-ba.jpg 42.6 kB 10/22/15, 2:45:16 PM
Target-diapers.jpg 41.0 kB 10/22/15, 2:43:05 PM
Thumbs.db 63.5 kB 10/22/15, 3:06:20 PM
The desired output would be a to remove everything save for the images, which, in this case, all have the .jpg
file extension type.
Intended result:
BamboNature.jpg
bjs1.jpg
BroodyChick.jpg
EarthsBest01.jpg
HonestDiaper.jpg
Huggies_1.jpg
Huggies_2.jpg
Luvs_2.jpg
Luvs.jpg
Munchkin.jpg
Pampers.jpg
Pampers02.jpg
parents-choice-unscented-ba.jpg
Target-diapers.jpg
Again, this should be able to be applied for any file type and will be a standalone regex to remove clutter from file directory listings.
Upvotes: 0
Views: 397
Reputation: 1652
I would probably use a regular expression like this. I wrote it so it can even do file names that contain a space in them. Remember to turn on multi-line if you are doing the whole text at the same time.
^.*?\.\S{1,3}
description
^.*?\.\S{1,3}
Beginning of line or string
Any character, any number of repetitions, as few as possible
Literal .
Anything other than whitespace, between 1 and 3 repetition
Particularly for notepad++, you can use the find&replace feature use these. make sure you Untick the ". matches newline" then do:
Find what : (^.*?\.\S{1,3})(.*)
Replace with : \1
Upvotes: 1