#1 : 23/03-25 12:14 Bryonie Hopper
Posts: 11
|
Hi,
I've tried the forums but can't seem to find exactly what I'm looking for. I'd appreciate any help. I have a series of files that are almost the same, but have different variants: Cute kids and pets Color_Page_01 Cute kids and pets Dark_Page_01 I would like to be able to bring them all into AR at once and have them add an ending depending on what was contained in the original filename, so: Cute kids and pets_01_Color Cute kids and pets_Page_01_Dark I'm currently doing a seach for all filenames containing 'color' in Directory Opus (Windows File Exploere), taking them into AR and running this script: New Name - using the directory name and then Add -'color' Then I search for all filenames containing 'dark' and do the same thing but add 'dark' at the end instead. I just wondered if it was possible to do it all at once with a conditional script. Thanks for your help Bryonie |
#2 : 23/03-25 12:34 Delta Foxtrot
Posts: 459
|
Reply to #1:
Hi Bryonie, This should do pretty much what you are asking for. REPLACE method: Replace: ^(.*) (color|dark)_Page(.*)$ Replace with: $1$3_$2 Occurrence: All Case sensitive: UNCHECKED Regular expressions: CHECKED Apply to: Name Screenshot: https://drive.google.com/file/d/1IXLEybsGc0LwyfR QmMSQqICCkb1-1C5d/view?usp=sharing If you have more words you'd like to move to the end of the filename you can add them to the "Replace:" field in the second set of parentheses. Just put another vertical bar, or "pipe", between each word like I've done in the above example. For instance, if you have "bright" and "sunny" you'd have: Replace: ^(.*) (color|dark|bright|sunny)_Page(.*)$ (The "Replace with:" field wouldn't need to be changed) Best, DF |
#3 : 24/03-25 10:33 Bryonie Hopper
Posts: 11
|
Reply to #2:
Thanks for your suggestion. I'm not exactly a power user and so I'm not sure how your suggestion works. I've figured out that the $ signs refer to the placement of the words in the original filename. So you're rearranging them. $1 is the first word, $2 is the second etc. Does (.*) refer to anything before the specified words and then anything after? This means your idea is dependent on the structure of the filename being exactly how I want it to begin with. Is that correct? Unfortunately this isn't the case. I get the files from different people and the structure of the filename varies wildly. That's why I was just giving it a completely new name (from the directory) and then appending the variation (color or dark) depending on if color or dark where in the original. I just had to do that manually and wondered if it was possible to do contitionally. This is what I've been doing: New Name - <DirName:1>_<Inc NrDir:01> Add - dark. Or add colour if it's color. Also - I apolgise for the mispelling of 'colour' - most of the places where I get these files spell it 'color' :-( Sorry to probably be asking very basic things. |
#4 : 24/03-25 12:28 Delta Foxtrot
Posts: 459
|
Reply to #3:
Hello again, Did you try the solution I gave you? It should work on any file that has one of the words you listed, and I showed you the way to add more words. (.*) in a regular expression just says to match any character zero or more times, and assign it to a "variable", or "container", that can be called in the replacement phase. $1 refers to the first parentheses–anything before one of the words we are looking for, $2 the second (the words we are searching for) and $3 is anything after one of those words. That's why the replacement field gets $1 $3_$2, because we are moving $2 from the middle to the end. You don't really need to understand regular expressions to use the solution I suggested. If you do want to learn more about using regular expressions there are any number of references and tutorials on the internet. As to adding <Dir Name:1> and <IncNrDir>, you can still do that as well. Just experiment with where you want them to go. And "colour" can just be another word in $2. Best, DF |
#5 : 24/03-25 15:21 Bryonie Hopper
Posts: 11
|
Reply to #4:
Hi DF. Yep, I gave it a go, but I've had to take it a step further. I had to firstly get rid of the underscores so that the Replace knew where the words were. I don't now if I needed to do that or if there was a way of telling AR to use underscores instead of spaces to divide up the phrase, but it worked anyway. Replace - '_' Replace with ' ' I then made it so that only 'Colour' or 'Dark' are reproduced in the name, simply getting rid of $1 and $3 in the replace field. Replace - ^(.*) (Colour|Dark) (.*)$ Replace with - _$2 Add - <DirName:1>_<Inc NrDir:01> at the beginning Works like a charm! Thanks so much. |