Skip to content

Instantly share code, notes, and snippets.

@Lucs1590
Created April 25, 2020 19:17
Show Gist options
  • Save Lucs1590/23bea150cdda941af0749f951663e886 to your computer and use it in GitHub Desktop.
Save Lucs1590/23bea150cdda941af0749f951663e886 to your computer and use it in GitHub Desktop.
This is a code to remove a lot of things using Python 3
import os
import glob
import pandas as pd
def main():
data = pd.read_csv('/path/of/txt/', sep=" ", header=None)[0].values.tolist()
caminho = "/path/of/files"
finded = 0
deleted = 0
for arquivo in glob.glob(os.path.join(caminho, "*.jpg")):
arquivo = arquivo.replace(caminho,'')
try:
data.index(arquivo)
finded += 1
except:
os.remove(caminho + arquivo)
deleted += 1
print("Encontrados: ", finded)
print("Deletados: ", deleted)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment