Simple question about using utility

A swapping-ground for Regular Expression syntax

Simple question about using utility

Postby mumzie » Mon Oct 10, 2016 1:08 am

I used to be a regular RegEx user. I used to remember all that stuff.
Left the industry after 30 years, and now have CRS disease.

I just need to use the utility to rename files (all in the same directory. hundreds of unique "filename" values) from filename_1.jpg to filename.jpg

There are other files in the directory filename_x.jpg - just want to rename the ones with _1 - not _11, _12, etc.

Can someone help?
mumzie
 
Posts: 3
Joined: Mon Oct 10, 2016 1:04 am

Re: Simple question about using utility

Postby KenP » Mon Oct 10, 2016 1:46 pm

Can't really say how to rename the files without more information, but if you just want to filter the files with _1 so you can rename them this should work.

To filter the files that end with _1.xxx

Filters (12)
Mask: _1\.
RegEx


If you also want to filter files that have _1 not at the end of the file name i.e. file-name _1 file-name.xxx

Filters (12)
Mask: _1\D|_1\.
RegEx


If you also want to filter files that end with 1 without the underscore i.e. file-name 1.xxx

Filters (12)
Mask: _1\D|_1\.|\D1\.
RegEx
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: Simple question about using utility

Postby mumzie » Tue Oct 11, 2016 1:37 am

Memory of regex is tentative at best.
In Dos command line syntax - rename *_1.jpg *.jpg

That's it. I want to strip off the _1. Not the _1 from filename_12.jpg, JUST the one that is *_1.jpg
mumzie
 
Posts: 3
Joined: Mon Oct 10, 2016 1:04 am

Re: Simple question about using utility

Postby KenP » Tue Oct 11, 2016 10:06 am

To delete just the _1 where it's at the end of the file name i.e. SomeFileName_1.xxx try this.
(This will rename files ending with _1 but will not rename files ending _11 or _12 ec't)

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


If you want to filter the files so you only see the files that end with _1.xxx while you work with them you can filter them as bellow.

Filters (12) _1\.
RegEx
KenP
 
Posts: 193
Joined: Sat Jul 30, 2016 11:25 am

Re: Simple question about using utility

Postby mumzie » Mon Oct 24, 2016 4:24 am

thank you.
mumzie
 
Posts: 3
Joined: Mon Oct 10, 2016 1:04 am


Return to Regular Expressions


cron