renaming filename

Advanced Renamer forum
#1 : 22/07-19 02:38
kwapster
kwapster
Posts: 5
So i have files in the following random format

Mike Brown ITT500 - James and Warshall brown.mp4
David Smith_ITT802_Jul 10_Disk Scheduling & Replacement Cont'd.mp4

basically i need to always be able to rename the files to only the file names eg

James and Warshall brown.mp4
Disk Scheduling & Page Replacement Cont'd.mp4

So i need to always remove whatever characters are in front of "_ or -"


22/07-19 02:38 - edited 22/07-19 02:40
#2 : 22/07-19 09:02
Will Robinson
Will Robinson
Posts: 5
Reply to #1:
Hi,

Using 'Replace'...
Text to be replaced:
.*(-|_) ?(.*)
Replace with:
$2
Occurrence: All
Case sensitive: No
Use regular expressions: Yes
Apply to: Name only

Info:
.* - Mark all text until...
(-|_) - either of these, which...
? - May or may not be followed by a space.
(.*) - Capture remaining text into a group.

The $2 is the group we captured/copied to swap back in.

Hope this helps.


22/07-19 09:02
#3 : 22/07-19 09:08
David Lee
David Lee
Posts: 245
Reply to #1:
You need to use a regular expression - as explained in the User Guide: www.advancedrenamer.com/user_guide/regular_expresions

Use the Remove method with the pattern .*[-_] ?

Note that the pattern ends with "<space>?" (removes zero or one spaces following the "-" or "_").


22/07-19 09:08
#4 : 22/07-19 17:12
kwapster
kwapster
Posts: 5
thank you both!

I didn't realize i have now lost the ability to identify the files uniquely.

would it be possible to keep the 5 character unique string? eg

ITT802 Disk Scheduling & Replacement Cont'd.mp4
ITT500 James and Warshall brown.mp4


22/07-19 17:12
#5 : 22/07-19 20:40
David Lee
David Lee
Posts: 245
Reply to #4:
I assume that you meant "6 character unique string" and that it can be any three upper case alpha characters followed by any three digits.

if so then then use the Replace method with the following regular expression (without the quotes):
".*([A-Z]{3}[0-9]{3}).*[-_] ?"

and replace with "\1 "

Note the space after \1

(Also $1 and \1 have the same functionality for returning numbered "sub-patterns" but \1 is the version that Kim uses in the User Guide)


22/07-19 20:40
#6 : 22/07-19 23:13
kwapster
kwapster
Posts: 5
Reply to #5:
exactly what i was looking for thanks for the help


22/07-19 23:13