Created
June 24, 2017 06:17
-
-
Save ihfazhillah/55c1848e218d14fffe068423077f408e to your computer and use it in GitHub Desktop.
rename list of file to number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Suppose we have list of file like this | |
abcd-1.mp3 | |
defg-2.mp3 | |
in our folder. And we need to play all of these in sequence. | |
In my case, i will rename it to just an number like: | |
1.mp3 | |
2.mp3 | |
""" | |
import os | |
import re | |
# make sure, that you run this code in same folder with the audio files | |
for audio in os.listdir(): | |
os.rename(audio, re.search("\d+", audio).group(0) + ".mp3") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment