Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created December 27, 2021 08:14
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 e96031413/c1096702d45c85de0130a2772cebfe27 to your computer and use it in GitHub Desktop.
Save e96031413/c1096702d45c85de0130a2772cebfe27 to your computer and use it in GitHub Desktop.
Copy file to a specific folder with paths in a txt file
import os
import shutil
fileListingFile = "missclassified_file_path.txt"
outputDir = "./"
# sample path in txt: /root/notebooks/XXXXX/datasets/XXXXXXXX.jpg
with open(fileListingFile, "r") as file:
fileNames = [file.strip() for file in file.readlines()]
for file in fileNames:
shutil.copy(file, os.path.join(outputDir, file.split("/")[-1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment