Created
October 20, 2011 03:56
-
-
Save mark-cooper/1300380 to your computer and use it in GitHub Desktop.
Count occurrences of file basenames from a single folder and select those that appear once ...
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
from os import listdir | |
from os.path import basename, isfile, join, splitext | |
src_dir = 'c:\\repository\\' | |
files = {} | |
for file in listdir(src_dir): | |
src_file = join(src_dir, file) | |
if isfile(src_file): | |
base = splitext(basename(src_file))[0] | |
if base in files: | |
files[base] += 1 | |
else: | |
files[base] = 1 | |
unique = [file for file in files.keys() if files[file] == 1] | |
print unique |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment