Created
November 11, 2018 17:44
-
-
Save krared/9e0036851f6602b131667801e92dccb0 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, shutil | |
from multiprocessing import Pool | |
def get_img_path(folder): | |
return (os.path.join(folder, f) | |
for f in os.listdir(folder) | |
if 'jpg' in f) | |
name = 'obj' | |
def rename_move(filename): | |
os.rename(filename[1], '{}_{}.jpg'.format(name,filename[0])) | |
if __name__ == '__main__': | |
folder = os.getcwd() | |
images = get_img_path(folder) | |
img_c = list(enumerate(images, 0)) | |
pool = Pool() | |
pool.map(rename_move, img_c) | |
pool.close() | |
pool.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment