Page 1 of 1

How to remove everything after a certain two characters

PostPosted: Wed Oct 19, 2016 12:58 pm
by WonderPhil
Hi,
As is says in the title, I'm wanting to remove everything after two characters (The first instance of T2 in the below example) but there are variations which makes it difficult.

For example:

14692-2A-010-A-24-0-T2-62-14692-2A-010-A-24-0 T2

Needs to become:

14692-2A-010-A-24-0-T2

The issue is, the amount of characters before the first instance of T2 can change as well as the number after T.
To help try and clear things up if there is confusion, here is another example:

14692-2A-1100-A-32-5-T6-109-14692-2A-1100-A-32-5 T6

In this example, it needs to be trimmed after the first instance of T6.

If somebody could help, I would very much appreciate it!

Thanks.

Re: How to remove everything after a certain two characters

PostPosted: Wed Oct 19, 2016 1:45 pm
by KenP
Try this.

RegEx (1)
Match: (\S*-T\d)(-.*)
Replace: \1

Re: How to remove everything after a certain two characters

PostPosted: Wed Oct 19, 2016 2:09 pm
by WonderPhil
KenP wrote:Try this.

RegEx (1)
Match: (\S*-T\d)(-.*)
Replace: \1


Brilliant! Thank you. That will save a huge amount of time.

Re: How to remove everything after a certain two characters

PostPosted: Sun Dec 11, 2016 11:18 am
by SteelWolf
I too have the same question.
data (2015_02_24 09_59_31 UTC).js
"space(*)" is what i'm trying to remove. The space(*) was added by windows back up So there are many sub folders and files that have the date added.
The big problem is that all the added information is breaking web pages I am trying to resurrect.
I've tryed a two step process of cropping everything after a "space" then removing the space. But in the folder copied to after editing the files are all dumped into a main directory. So i'll try making a copy of the main web sites folder (2) and then just editing that inplace with out moving/coping renamed files into new locations.
Thanks.

Volume in drive C is Windows
Volume Serial Number is 26B4-B7DF

Directory of \web sites

12/11/2016 03:13 AM <DIR> .
12/11/2016 03:13 AM <DIR> ..
12/11/2016 02:24 AM <DIR> DC
12/11/2016 02:24 AM <DIR> dc5
12/11/2016 03:13 AM 0 filelist.txt
03/15/2013 11:35 PM 908 index (2015_02_24 09_59_31 UTC).htm
12/11/2016 02:24 AM <DIR> p18
12/11/2016 02:24 AM <DIR> sr
2 File(s) 908 bytes

Directory of \web sites\DC

12/11/2016 02:24 AM <DIR> .
12/11/2016 02:24 AM <DIR> ..
12/11/2016 02:24 AM <DIR> awards
03/15/2013 11:35 PM 21,388 awards (2015_02_24 09_59_31 UTC).htm
03/15/2013 11:35 PM 1,155 center (2015_02_24 09_59_31 UTC).JPG
03/15/2013 11:35 PM 97,316 chest (2015_02_24 09_59_31 UTC).jpg
03/15/2013 11:35 PM 7,621 code (2015_02_24 09_59_31 UTC).htm
03/15/2013 11:35 PM 7,971 dark1logo (2015_02_24 09_59_31 UTC).jpg
03/15/2013 11:35 PM 2,664 dateheader-bg (2015_02_24 09_59_31 UTC).gif
03/15/2013 11:35 PM 722 dateheader-left[1] (2015_02_24 09_59_31 UTC).gif
03/15/2013 11:35 PM 488 dateheader-right (2015_02_24 09_59_31 UTC).gif
03/15/2013 11:35 PM 136,857 dcbank (2015_02_24 09_59_31 UTC).htm
03/15/2013 11:35 PM 1,472 DKP (2015_02_24 09_59_31 UTC).htm
03/15/2013 11:35 PM 822 favicon (2015_02_24 09_59_31 UTC).bmp
03/15/2013 11:35 PM 867 forums (2015_02_24 09_59_31 UTC).htm
03/15/2013 11:35 PM 732 guidelines_main_page2 (2015_02_24 09_59_31 UTC).htm
03/15/2013 11:35 PM 7,416 guidemenu (2015_02_24 09_59_31 UTC).htm
03/15/2013 11:35 PM 15,732 guildmaster (2015_02_24 09_59_31 UTC).jpg
03/15/2013 11:35 PM 499 header (2015_02_24 09_59_31 UTC).htm
12/11/2016 02:24 AM <DIR> images
03/15/2013 11:35 PM 813 index (2015_02_24 09_59_31 UTC).htm
03/15/2013 11:35 PM 3,034 introduction (2015_02_24 09_59_31 UTC).htm

(SNIP) and about 900 more files

Total Files Listed:
552 File(s) 57,890,351 bytes
98 Dir(s) 351,951,511,552 bytes free

Re: How to remove everything after a certain two characters

PostPosted: Sun Dec 11, 2016 12:15 pm
by KenP
The slash / in the dates is not valid in Windows file names so I'm not sure how you get over that, but from what you've said it sounds like you know how to overcome that problem.

Try this.

RegEx (1)
Match: (.*) \(.*\)
Replace: \1

Re: How to remove everything after a certain two characters

PostPosted: Tue Dec 13, 2016 12:23 am
by Admin
BTW an alternative but more basic way to do this is to use Remove (5) -> Crop (After) and specify the two characters to crop the file name after.