remove hash in the form [XXXXXXXX]

Advanced Renamer forum
#1 : 25/04-18 20:50
psiphre
psiphre
Posts: 1
i'm trying to write a method that will remove hashes from file names that take the form "[XXXXXXXX]", where X can be any number or capital letter. i'm having difficulty. can someone point me in the right direction?


25/04-18 20:50
#2 : 26/04-18 00:56
Mark
Mark
Posts: 175
Reply to #1:
Try a RegEx ....

Given abcde[XXXXXX]fghij.txt

Replace method
Text to be replaced: (.*)[[](.*)[]](.*)
Replace with: \1\3
Occurrence: All
Case sensitive: not ticked
Use regular expressions: ticked
Apply to: Name

gives abcdefghij.txt

Or something like that ....

(.*)(\[.*])
\1

also seems to work. I understand a bit of RegEx but I'm not an expert ... but it's the way to manage this requirement.


26/04-18 00:56
#3 : 26/04-18 09:22
Stefan
Stefan
Posts: 274
Reply to #2:

Or ...

FROM:
A Test [XXXXXXXX].ext
B Test [XXXXxxXXXX] Test.ext
C Test [XX12af345bc72daxxxx] Test.ext

TO:
A Test .ext
B Test Test.ext
C Test Test.ext


USE:
"Remove pattern" method ( https://www.advancedrenamer.com/user_guide/metho d_removepattern )

Pattern: \[.+]
[√] Use regular expressions






Explanation:

"[" >>> is a special RegEx sign, so we escape it
to say "I want really literately a [-sign" >>> \[

".+" >>> will match one-or-more of any sign, until...

"]" >>>a literately ]-sign is found.
( for some regex-engine this closing bracket also needs to be escaped >> \] ,
but not for ARens regex-engine as it seems )






HTH?


26/04-18 09:22 - edited 26/04-18 09:23
#4 : 26/04-18 09:54
Mark
Mark
Posts: 175
Reply to #3:
Good one Stefan! I learn again ....

How would \[.+] differ from \[.*]

I haven't got my head around the + vs the * .... I know the "Match 1 or more" vs "Match 0 or more", but they seem to work the same way, mostly.

More importantly, I forgot about the Remove Pattern method :)

Mark


26/04-18 09:54 - edited 26/04-18 11:53