Deleting words from the filename - not working after update 4.14
Hello! Random user & first time poster here. Thanks for this great program!
I've run into a bit of a problem after update 4.14.
I need to delete all the words but the last one from a set of filenames.
First I've taken the filenames from the folder name and added numbering to the end with this:
New Name
<DirName:1><Inc NrDir:1>
Then cleaning the filenames with this:
Remove pattern
<Word:1> \<Word:2> \(<Word:2>) \<Word:3> \(<Word:3>) \<Word:4> \(<Word:4>) \!
There's never more than 4 words to remove and the words can sometimes be in parentheses.
Obviously my method is a horrible mess :) I don't even remember why there is a "!" in the end :D
I don't know how I've come up with this :D but it works in version 4.13.
The problem is, it stopped working in version 4.14 and hasn't worked since.
Any idea why it doesn't work anymore and/or how to do this properly? :)
I've run into a bit of a problem after update 4.14.
I need to delete all the words but the last one from a set of filenames.
First I've taken the filenames from the folder name and added numbering to the end with this:
New Name
<DirName:1><Inc NrDir:1>
Then cleaning the filenames with this:
Remove pattern
<Word:1> \<Word:2> \(<Word:2>) \<Word:3> \(<Word:3>) \<Word:4> \(<Word:4>) \!
There's never more than 4 words to remove and the words can sometimes be in parentheses.
Obviously my method is a horrible mess :) I don't even remember why there is a "!" in the end :D
I don't know how I've come up with this :D but it works in version 4.13.
The problem is, it stopped working in version 4.14 and hasn't worked since.
Any idea why it doesn't work anymore and/or how to do this properly? :)
Hi Robbo,
Well, normally I'd say use an <RSubstr:1:" "> tag to capture everything from the last character backwards to the first space, but that doesn't seem to be working correctly either.
But here's something that should work every time: Keep your New Name method, then use a REPLACE method. We'll be replacing "everything" with "everything after the last word boundary":
Replace: ^.*\b(.+)$
Replace with: $1
Use regular expressions: CHECKED
Apply to: Name
What we're replacing:
^ = start at the 1st character
.* = throw away everything...
\b = up to a word boundary
(.+) = ...followed by some characters that we capture...
$ = ...followed by the end of the filename
What we're replacing with:
$1 = the characters we captured with the parentheses above.
(If my explanation doesn't make sense you might try pasting that first expression into one of the online regex engines, like regex101.com)
That should be reliable for you. Don't forget to turn on regular expressions! :)
Best,
DF
Well, normally I'd say use an <RSubstr:1:" "> tag to capture everything from the last character backwards to the first space, but that doesn't seem to be working correctly either.
But here's something that should work every time: Keep your New Name method, then use a REPLACE method. We'll be replacing "everything" with "everything after the last word boundary":
Replace: ^.*\b(.+)$
Replace with: $1
Use regular expressions: CHECKED
Apply to: Name
What we're replacing:
^ = start at the 1st character
.* = throw away everything...
\b = up to a word boundary
(.+) = ...followed by some characters that we capture...
$ = ...followed by the end of the filename
What we're replacing with:
$1 = the characters we captured with the parentheses above.
(If my explanation doesn't make sense you might try pasting that first expression into one of the online regex engines, like regex101.com)
That should be reliable for you. Don't forget to turn on regular expressions! :)
Best,
DF
Reply to #2:
Robbo,
When Kim gets <RSubstr> working again, here's how you can do it (or if you're using a version where <RSubstr> works). Keep the New Name method, then use this Replace method:
Replace: *
[Just an asterisk]
Replace with: <RSubstr:1:" ">
That's it.
And if anyone is interested, here's how to do the whole process with 3 lines of javascript:
x = app.parseTags('<foldername>');
y = x.lastIndexOf(" ");
return ( y > -1 ? x.slice( y,x.length ) : x ) + (index+1);
Best,
DF
Robbo,
When Kim gets <RSubstr> working again, here's how you can do it (or if you're using a version where <RSubstr> works). Keep the New Name method, then use this Replace method:
Replace: *
[Just an asterisk]
Replace with: <RSubstr:1:" ">
That's it.
And if anyone is interested, here's how to do the whole process with 3 lines of javascript:
x = app.parseTags('<foldername>');
y = x.lastIndexOf(" ");
return ( y > -1 ? x.slice( y,x.length ) : x ) + (index+1);
Best,
DF
Thank you for the advice!
I'll definitely try the regex version explained in message #2.
Right now (on version 4.13) the Replace with: <RSubstr:1:" "> method gives me the last word from the filename but it's missing the first letter of the word.
But here's enough to go forward anyway. Thank You!
I'll definitely try the regex version explained in message #2.
Right now (on version 4.13) the Replace with: <RSubstr:1:" "> method gives me the last word from the filename but it's missing the first letter of the word.
But here's enough to go forward anyway. Thank You!
Reply to #4:
Yeah, that's the same thing that's happening on version 4.17, and why I suggested the regex solution. It will work for you.
Best,
DF
Yeah, that's the same thing that's happening on version 4.17, and why I suggested the regex solution. It will work for you.
Best,
DF
Reply to #5:
Yeah thanks, I just checked the regex solution. Works!
Yeah thanks, I just checked the regex solution. Works!