#1 : 02/03-24 23:26 raf
Posts: 12
|
Hello
I have random files and I'd like to rename the filenames to preserve 5 characters from the end of the name, but all files have different lenghts. How would I go about scripting this in advanced renamer? alexconsani_1703461883_3265197398812440395_424427677 HvLPHTo noVUg93 vavallogic_1709370658_3314763793966458118_57376711638 The result would be: 27677 LPHTo VUg93 711638 Tried the regular expression: (.*)([^\.]+)\.(.*) then replace with \2 but gave nothing good. ChatGPT not helping here Thanks |
#2 : 03/03-24 04:02 Delta Foxtrot
Posts: 285
|
Hey raf,
How about this: 1.Method MOVE (move 5 chars at end to beginning) Move from 1 Move count 5 Move to 1000 Backwards: CHECKED Use Regex OFF 2. Method REMOVE (everthing after 5th char) Remove count 1000 Starting at 6 Backwards UNCHECKED (!) Regex OFF Booya! :) I doubt it makes a difference, but if you have a lot of files it MIGHT be more efficient to make the "move to" and "remove count" fields as low as possible to be effective on all your files. Best, DF |
#3 : 03/03-24 05:26 Styb
Posts: 101
|
Reply to #1:
Hello, Add a specific separator string delimiting the last 5 characters, and then you can delete the first portion of filename. ADD Add: -@- In position: 5 backwards REPLACE Replace: (.*)-@-(.*) With: \2 via regular expression. Here is the .aren file with the above two methods: https://www.mediafire.com/file/l6c9suaz2o7dumr/l ast5.aren/file |
#4 : 03/03-24 10:19 Miguel
Posts: 136
|
Reply to #1: Hi,
Another solution Replace: .*(\w{5})$ Replace with: $1 Use regex |
#5 : 03/03-24 11:38 Delta Foxtrot
Posts: 285
|
Reply to #4:
Hey Miguel, How ya doin' over there in paradise my friend? :) Sorry to be a Delta-downer, but that regex fails if there are non-word characters in the last 5 of the filename. There were none in raf's examples, but... you know Murphy. I substituted ^\\ for \w and it worked on a big sample of files, and I think it'll work consistently. Ya can't use "\" in a filename, but it works for the regex. So, .*([^\\]{5})$ should get the job done, and in one measly little method! :) I knew there was a way, but I just couldn't see it until you woke me up! There ya go raf, you've got choices! If you've got a lot of files you might start thinking about what you'll do for files that have the same last five characters (happened to me while testing the solutions). Best to all, DF |
#6 : 03/03-24 12:01 Miguel
Posts: 136
|
Reply to #5:
Hi Delta. You are right it fail if you use non words characters. My fault. Thank you. |
#7 : 03/03-24 13:39 raf
Posts: 12
|
Reply to #5:
oh wow, i didnt realise things like this could be done. And I am glad there are such smart people around here!!!! |
#8 : 03/03-24 13:40 raf
Posts: 12
|
Reply to #2:
thanks. Tried Delta's method and seemed to be the simplest. But thanks! |
#9 : 04/03-24 06:34 Delta Foxtrot
Posts: 285
|
Reply to #8:
An embarrassment of riches... New Name method: New name: <RSubstr:1:5> BOOM! :) DF |