Created
January 31, 2021 00:16
-
-
Save SirmaXX/f431fa9f98f1bac2f7908d946cc02687 to your computer and use it in GitHub Desktop.
same file finder script
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 | |
import sys | |
#usage | |
# python base.py 'first file path' 'sec file path' | |
#order of arguments | |
if __name__ == "__main__": | |
for i, arg in enumerate(sys.argv): | |
if i == 1: | |
path = arg | |
elif i == 2: | |
path1 = arg | |
else: | |
print(f"") | |
#our file list | |
firstfiles = [] | |
secfiles = [] | |
#list appender | |
def fileappender(path, list): | |
files = os.listdir(path) | |
for f in files: | |
list.append(f) | |
#common item finder | |
def commonelemnets(a, b): | |
seta = set(a) | |
setb = set(b) | |
if (seta & setb): | |
print("Common Files ::> \n", seta & setb) | |
else: | |
print("No common files") | |
#software | |
fileappender(path,firstfiles) | |
fileappender(path1,secfiles) | |
commonelemnets(firstfiles,secfiles) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment