Skip to content

Instantly share code, notes, and snippets.

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 dianjuar/b3016c8bc2bffe4962014f58b18f3f5e to your computer and use it in GitHub Desktop.
Save dianjuar/b3016c8bc2bffe4962014f58b18f3f5e to your computer and use it in GitHub Desktop.
Imagine a huge amount of files, you copy some of then to do something, then you want the files left. This code in python copy the files that are not copied yet that all. You need to generate a list of the copied files, you can do it with `ls > copied.txt`. At the end this script will generate a list with the remaining files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
def loadVectorFromFile( archiveName ):
vector = []
with open( archiveName, "r") as archive:
for line in archive:
vector.append(line)
return vector
destiny = '/run/media/dianjuar/Datos/NotCopied/'
copiedFiles = []
copiedFiles = loadVectorFromFile("Files.txt")
#the whole
allFiles = []
allFiles = loadVectorFromFile("everything.txt")
notCopiedFiles = list( set(allFiles) - set(copiedFiles) )
for notCpFile in notCopiedFiles:
notCpFile = notCpFile.replace('\n', '')
print ( 'processing - \"'+ str(notCpFile) +'\"' )
os.system ( 'cp \"'+str(notCpFile)+'\" '+destiny )
print("-----------------------------------")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment