#1 : 25/02-24 22:24 Bryonie Hopper
Posts: 7
|
Hi.
I have a directory named: AP_001_african-wild-animals-set In that directory I have 2 files named: Asset [email protected] Asset 4.svg I want the first 7 characters of the directory name appended to the beginning of each file name. I can already clean up the file name (take away the 'Asset' and '@10x') and add the full directory name, but I can't add PART of the directory name. I don't want to add the full directory name as the file name becomes unwieldy, and in some cases, unuseable. I also need to keep the number after 'Asset', so that the pairs of pngs and svgs stay the same (I can't just crop the directory name and have Advanced Renamer add a counter) I have multiple pairs of png/svg files in each directory across many directories. Unfortunately these directories have greatly varying names after the first 7 characters. For example, another directory is: AP_008_Collection-hand-drawn-dog-eight-different-postures I've seen various people ask similar questions, but none of the solutions work when the directories are different lengths. Any ideas? Thanks in advance :-) Bryonie |
#2 : 25/02-24 23:27 Delta Foxtrot
Posts: 323
|
Hi Bryonie,
I would use an add method to add the full directory name, plus a marker character (it can be anything not found in either the directory name or any of the filenames, something like Alt-174 ®. Then use a replace method to whittle down the full directory name to the N number of characters you prefer. ADD METHOD: Add: <Dirname:1>® At index: 1 [all other options default] REPLACE METHOD: Replace: (.{7}).*® Replace with: $1 That's it. Easy squeezy. Best, DF |
#3 : 26/02-24 09:17 Bryonie Hopper
Posts: 7
|
Reply to #2:
Hi Delta, That's exactly what I wanted - I just have to figure out what it all means now so that I can use it in for other situations ;-) Like any solution in AR, that has saved me hours of work now and in the future. Thank you so much! Bryonie |
#4 : 26/02-24 22:06 Delta Foxtrot
Posts: 323
|
Reply to #3:
Glad to help. Like so many have done for me over the years. As to what it means, I don't know where your level of understanding of regex is at, so not to talk down to you, but I found that once I started thinking of anything in a pair of parentheses as an entity that is being stored for possible further use, things became a lot simpler. So the stuff in the parentheses are a period (any character encountered) and curlies with a seven (that just means seven of the previous operator, the period. So we just stored seven characters at the start of the filename. Then the regex just grinds through the following characters (the "any character" period again, but this time with a "*" - zero to infinity characters, until it hits the ®, where it knows that its job is done. The $1 in the Replace with: box just puts back the stuff we stored from the parentheses. Hope that helps. DF |