Last active
May 20, 2016 15:25
-
-
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
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
#!/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