Created
November 26, 2017 12:24
-
-
Save girisagar46/4846b62bd7c1c52770987e7b864efc22 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 glob | |
import os | |
import sys | |
""" | |
Sagar Giri | |
[email protected] | |
https://github.com/girisagar46 | |
""" | |
search_dir = None | |
if len(sys.argv) > 1 and sys.argv[1] == '.': | |
print("Searching in specified directory: {}".format(os.getcwd())) | |
search_dir = os.path.join(os.getcwd(), '') | |
elif len(sys.argv) > 1: | |
print("Searching in specified directory: {}".format(sys.argv[1])) | |
search_dir = os.path.join(sys.argv[1], '') | |
else: | |
print("Please specify where to search.") | |
exit(0) | |
png_files = [] | |
search_pattern_1 = search_dir + '**/*.png' | |
search_pattern_2 = search_dir + '**/*.PNG' | |
def search_png(): | |
""" | |
Usage: $ python3 pyngsearch.py [<arguments>] | |
:return: NoneType | |
""" | |
for filename in glob.iglob(search_pattern_1, recursive=True): | |
png_files.append(filename) | |
for filename in glob.iglob(search_pattern_2, recursive=True): | |
png_files.append(filename) | |
if __name__ == '__main__': | |
search_png() | |
print('{} png/PNG files found.'.format(len(png_files))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment