Rename based on other filename that was just renamed

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Hello all, newbie here and have been trying to read posts but haven't found anything on this specific issue I'm trying to do.

Will try to be concise.

There is a batch of auto-generated files that I'm trying to rename nightly.

-I have a content-matching PDF rule that I eventually got to work and rename a PDF into a format I like.
-not all files are PDF and don't have adequate content to match with. However the auto-generated filenames have portions of names that I can use to identify what report it is.

I want to take any of the remaining files that have NOT been renamed and follow the naming convention from the PDF I just managed to rename. These files would then get moved into a sub-folder or elsewhere on my own so the watch folder would be empty the next night.

Let me see if I can make an example:

ZZZZ reportname1- 7 D12 of 22.pdf (this is the one I am able to parse and rename)
ZZZZ diffreportname2-7 EP2 - D12 of 22.txt
ZZZZ diffreportname3 - 7 - D 12 - 22.txt

and I'm wanting to rename all of the files into:

ZZZZ reportname1 107 D12 of 22.pdf
ZZZZ diffreportname2 107 D12 of 22.txt
ZZZZ diffreportname3 107 D12 of 22.txt

Now... the problem comes when the diffreportname2 or diffreportname3 have variable spacing and stuff around them as they are generated. Yes I know the output generation should get fixed, but I can't do that.

The report names themselves always are there.

So my hope is to use the correct file-naming from the first PDF, then do a filename search for the just 'diffreportname2' for other files that dropped at the same time and then use all of the other information from the filename of the PDF I fixed to format these other reports correctly. These variables change nightly: ZZZZ, 107, D12, 22

This is why its a little funky.

I've been trying to look into bash scripting and things too.

Anyone have any ideas where to go look into this kind of renaming?

Thanks everyone
CaptainPower
 
Posts: 1
Joined: Sat Feb 27, 2021 6:45 pm

Look up "nested conditions" in the manual. You can set up rules to match other files in the same folder. You can do a pattern matching rule if you'd like. It would look something like:
Code: Select all
If (all) are met
    If (all) are met for (files in the same folder)
        Names matches <<some pattern with a custom attribute matching the reportname stuff you want to extract>>

You can then use the custom attribute to rename the other files appropriately.
Mr_Noodle
Site Admin
 
Posts: 11236
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support