Replace specific naming withing file name

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Replace specific naming withing file name

Postby jkaplan » Thu Jun 02, 2016 7:23 pm

I have multiple files with the following naming conventions:

US-FL-xxxx-A-xxxxx
US-FL-xxxx-B-xxxxx
US-FL-xxxx-C-xxxxx
...

The x's are numbers that vary per file. The A,B,C, needs to be removed. Note the actual files do not read ABC, but names of different places. Is there a way to remove the "ABC" but keep the rest.
jkaplan
 
Posts: 3
Joined: Thu Jun 02, 2016 7:16 pm

Re: Replace specific naming withing file name

Postby therube » Fri Jun 03, 2016 1:06 am

Could you provide examples of actual filenames.

US-FL-, is fixed?
And then always four digits?
A,B,C, are variable length "words" (counties or whatever)?
Are any of them hyphenated?
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Replace specific naming withing file name

Postby Admin » Fri Jun 03, 2016 3:13 am

Please also post 5 names as real examples, from -> to renaming required
thanks
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Replace specific naming withing file name

Postby jkaplan » Fri Jun 03, 2016 2:58 pm

US-AK-4002_Kodiak_North_P1_042616.pdf
US-AK-4011_Kodiak_Launch_P1_042616.pdf
US-AK-5012_Commercial_Drive_P1_042616.pdf
US-AK-5013_59th_Signal_Battalion_P1_042616.pdf
US-AK-5014_Mile_High_P1_041916.pdf
US-AK-5015_Blue_Tin_P1_041316.pdf
US-AK-5016 South Side Dental_P1_042116.pdf
US-AK-5017_Chapel_by_the_Sea_P1_041416.pdf
US-AK-5018 United Pentecostal_P1_042416.pdf
US-AK-5019 Service Water Tower_P1_042116.pdf

Need to remove the middle parts aka "Kodiak North", "Kodiak Launch", etc.

US-AK-4002_042616.pdf
US-AK-4011_042616.pdf
US-AK-5012_042616.pdf
US-AK-5013_042616.pdf
US-AK-5014_041916.pdf
US-AK-5015_041316.pdf
US-AK-5016_041416.pdf
US-AK-5018_042416.pdf
US-AK-5019_042116.pdf
jkaplan
 
Posts: 3
Joined: Thu Jun 02, 2016 7:16 pm

Re: Replace specific naming withing file name

Postby therube » Fri Jun 03, 2016 3:19 pm

Is the "P1" part in every file, or does that vary?

I guess that doesn't matter, so long as you can match on the "_"''s.


1:RegEx

Code: Select all
Match:  (..........)(_.*_)(.+)
Replace:  \1_\3
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Replace specific naming withing file name

Postby jkaplan » Fri Jun 03, 2016 4:11 pm

It is in every file. Can you please walk me through how to do this. Thanks! also I need the P1 to show in every file
Last edited by jkaplan on Fri Jun 03, 2016 4:46 pm, edited 1 time in total.
jkaplan
 
Posts: 3
Joined: Thu Jun 02, 2016 7:16 pm

Re: Replace specific naming withing file name

Postby therube » Fri Jun 03, 2016 4:34 pm

Just paste the codes I show into the RegEx(1) box.
Then review the results - very carefully, to make sure its doing what you need (& that I didn't screw up ;-).)
(I'm very new to this & only have a basic understanding, if you want to call it that, as to what's going on.)

Image
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to Javascript Renaming