Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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