Created
August 4, 2020 07:24
-
-
Save chiehpower/22877f32ff14954c44ab4db879b37143 to your computer and use it in GitHub Desktop.
This file contains 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
import os | |
def batch_rename(path): | |
count = 0 | |
total = len(os.listdir(path)) | |
for fname in os.listdir(path): | |
time = total - len(str(count)) | |
Extension = fname.split('.')[-1] | |
new_fname = str(0*(time)) + str(count) + '.' + Extension | |
print(os.path.join(path, fname), ' New file name >>> ', new_fname) | |
os.rename(os.path.join(path, fname), os.path.join(path, new_fname)) | |
count = count + 1 | |
path = input("Your data folder location") | |
# path = './dataset' | |
batch_rename(str(path)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a big issue in this script that if you implement more times, your some files will be covered to remove.
Again and again, and then it will remain few files.
Need to debug this issue...