Skip to content

Instantly share code, notes, and snippets.

@renanregis
Last active December 2, 2017 21:26
Show Gist options
  • Save renanregis/12b37a2e6a875f3c451ad33a3186b426 to your computer and use it in GitHub Desktop.
Save renanregis/12b37a2e6a875f3c451ad33a3186b426 to your computer and use it in GitHub Desktop.
import json
import os, shutil
path = "/mnt/volume-nyc3-01/imagens/"
with open('JSON/destaque_empresarial.json', encoding='utf-8') as json_file:
dados = json.load(json_file)
for p in dados:
dst_pasta = "/mnt/volume-nyc3-01/ROVIVOPortal/website/media/fotos_legado"
for file in os.listdir(path):
if p["pasta_imagem"] == file:
try:
if not os.path.exists(dst_pasta + "/" + file):
shutil.move(path + file, dst_pasta)
print("Pasta " + file + " movida para " + dst_pasta + "\n")
except OSError as err:
print("OS error: {0}".format(err))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment