Created
March 31, 2017 21:21
-
-
Save TimSC/fb8657c0fc9c21b37d129d7c2f393bc3 to your computer and use it in GitHub Desktop.
Extract every nth file
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
| import sys | |
| import os | |
| import shutil | |
| if __name__ == "__main__": | |
| if len(sys.argv) < 4: | |
| print ("Usage: {} src_folder dst_folder ith_frame".format(sys.argv[0])) | |
| exit(0) | |
| ithFrame = int(sys.argv[3]) | |
| if not os.path.exists(sys.argv[2]): | |
| os.makedirs(sys.argv[2]) | |
| li = list(os.listdir(sys.argv[1])) | |
| li.sort() | |
| for fina in li[::ithFrame]: | |
| shutil.copyfile(os.path.join(sys.argv[1], fina), os.path.join(sys.argv[2], fina)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment