• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Scripting assistance for batch file rename

Joined
Aug 21, 2015
Messages
1,891 (0.53/day)
Location
North Dakota
System Name Office
Processor Core i7 10700K
Motherboard Gigabyte Z590 Aourus Ultra
Cooling be quiet! Shadow Rock LP
Memory 16GB Patriot Viper Steel DDR4-3200
Video Card(s) Intel ARC A750
Storage PNY CS1030 250GB, Crucial MX500 2TB
Display(s) Dell S2719DGF
Case Fractal Define 7 Compact
Power Supply EVGA 550 G3
Mouse Logitech M705 Marthon
Keyboard Logitech G410
Software Windows 10 Pro 22H2
My script-fu is weak, as in white-belt weak, maybe not even that. I used to dabble in BASH scripting, but that was about 15 years ago and was never anything complex. Anyway, I've got several hundred audio files that have leading "garbage" characters in the filenames. For example:

073 - Artist - Title.mp3 should become
Artist - Title.mp3

The leading characters aren't uniform in format. Spacing, number length and delimiters can vary, so I'd be looking to lop off anything before the first alpha character. This could run in CMD, PowerShell, BASH, or potentially another Linux shell. Ideas, anyone?
 
Nobody? Either I'm in the wrong place, or am really good at coming up with difficult questions.
 

regex101.com to test regular expressions
 

regex101.com to test regular expressions

Thanks for this lead, W1zz! Time to see where I can go with it.
 
so I'd be looking to lop off anything before the first alpha character
Something like this will match alpha characters plus whitespace, followed by an alpha numeric extension at the end of the string.
Code:
([a-zA-Z ])+.([a-zA-Z0-9])+$

So if you have something like this:
Code:
566-==-*4544.3333.--File Name Goes Here.txt

It would match on this:
Code:
File Name Goes Here.txt

You could also use something like this:
Code:
^([^a-zA-Z])+

That would match the beginning of such a filename and you could replace it with empty string.
Code:
566-==-*4544.3333.--

I could make a more targeted expression with better criteria, but I think this fits what you asked for.
 
Back
Top