Created
October 20, 2017 22:02
-
-
Save tarrsalah/472e9c43a55ed685df8194580b48a18d 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 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