Renaming based on the contents of the original file name

A swapping-ground for Regular Expression syntax

Renaming based on the contents of the original file name

Postby lindemrm » Fri Aug 25, 2017 10:15 pm

Hello-

I have a group of files in which their file names contain some description of their content, ie title_isbn_Cover_5x8.pdf and title_isbn_Text_5x8.pdf.

I want to append the end of the file names with the paper they will be printed on, so if the original file name contains '_Cover_', I want to add '_10ptC1S' to the end of the files name and if the original name contains '_Text_', then I want to add '_50White'. I'm sure it'll need to be done in two batches, but I don't really have a good way to sort the files, thus the need for the searching for the character string in the file name...

Thanks-
-Rick
lindemrm
 
Posts: 1
Joined: Fri Aug 25, 2017 9:22 pm

Re: Renaming based on the contents of the original file name

Postby KenP » Fri Aug 25, 2017 11:05 pm

There are a couple of ways to do this.

To filter the files:
Filters (12)
Mask: *text*
Alternative Mask =*cover*

Then use

Add (7)
Suffix: _50White
Alternative Suffix = _10ptC1S



Alternatively you can use regex.
RegEx (1)
Match: (?i)(.*text.*)
Replace: \1_50White
    (The (?i) that starts the Match makes it case insensitive, so it's use is optional)

Obviously for the covers you'll change the Match to "(?i)(.*cover.*)" and the Replace to "\1'_10ptC1S"
KenP
 
Posts: 199
Joined: Sat Jul 30, 2016 11:25 am


Return to Regular Expressions