Skip to content

Instantly share code, notes, and snippets.

@tarrsalah
Created October 20, 2017 22:02
Show Gist options
  • Save tarrsalah/472e9c43a55ed685df8194580b48a18d to your computer and use it in GitHub Desktop.
Save tarrsalah/472e9c43a55ed685df8194580b48a18d to your computer and use it in GitHub Desktop.
import os
import shutil
src_dir = os.curdir
dst_dir = os.path.join(os.curdir, "dest")
filenames = os.path.join(os.curdir, "filenames.txt")
def get_filenames():
lines = []
with open(filenames) as file:
for line in file:
line = line.strip()
lines.append(line)
return lines
def main():
listed = get_filenames()
all = os.listdir(src_dir)
for file in all:
if file in listed:
src_file = os.path.join(src_dir, file)
shutil.copy(src_file, dst_dir)
print(file)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment