Created
April 25, 2020 19:17
-
-
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
This file contains hidden or 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
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