Last active
January 11, 2019 08:20
-
-
Save kingardor/662b2d626ee7df5bfe3533c33e8b719c to your computer and use it in GitHub Desktop.
To rename images for easier annotation and handling while training models
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
''' | |
Usage: python3 rename.py --input path1 --output path2 | |
''' | |
import os | |
import argparse | |
def argsparser(): | |
''' | |
To use arguments from command line. | |
''' | |
parser = argparse.ArgumentParser(description='Renamer script') | |
parser.add_argument('--input', dest='input', help='Input Directory', default='path1', type=str) | |
parser.add_argument('--output', dest='output', help='Output Directory', default='path2', type=str) | |
return parser.parse_args() | |
if __name__ == '__main__': | |
args = argsparser() | |
files = os.listdir(args.input) | |
c = 1 #Counter | |
for f in files: | |
os.rename(os.path.join(args.input, f), os.path.join(args.output, str(c)+'.jpg')) | |
c += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment