Skip to content

Instantly share code, notes, and snippets.

@SirmaXX
Created January 31, 2021 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SirmaXX/f431fa9f98f1bac2f7908d946cc02687 to your computer and use it in GitHub Desktop.
Save SirmaXX/f431fa9f98f1bac2f7908d946cc02687 to your computer and use it in GitHub Desktop.
same file finder script
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