I have a bunch of files that are in this pattern:
-Ae829mFAGGE.mp3 -tt2k8PGm-TI.mp3 -SVOuYquXuuc.mp3 -3y44BJgkdZs.mp3 -eH3giaIzONA.mp3
full filename example:
Song Name - [Song Artist]-p3j2NYZ8FKs.mp3
exepected result:
Song Name - [Song Artist].mp3
I want to remove everything between the '-' and '.' all characters in between have length of 11.
Edit: used barmars suggestion, and did this
for filename in glob.glob(f"{path}*.mp3"): new_name = re.sub(r"-[a-zA-Z0-9]{11}\.", ".", filename) os.rename(filename, new_name)
https://stackoverflow.com/questions/65839203/how-do-i-match-this-pattern-with-regex-python January 22, 2021 at 12:12PM
没有评论:
发表评论