Skip to content

Instantly share code, notes, and snippets.

@keremistan
Created February 9, 2020 18:36
Show Gist options
  • Save keremistan/7f81b8e225411691879d566f5a030514 to your computer and use it in GitHub Desktop.
Save keremistan/7f81b8e225411691879d566f5a030514 to your computer and use it in GitHub Desktop.
from os import path, getcwd, mkdir, walk
from shutil import copy2, copyfile
def klasorleri_gez(kynk, hdf):
butun_icerik = walk(kynk, False)
butun_icerik_liste = [i for i in butun_icerik]
for i in range(len(butun_icerik_liste)):
klasor = butun_icerik_liste[i]
klasor_adresi = klasor[0]
klasordeki_dosyalar = klasor[2]
for dosya in klasordeki_dosyalar:
dosya_adress = path.join(klasor_adresi, dosya)
if '.jpg' in dosya_adress or '.png' in dosya_adress or '.jpeg' in dosya_adress:
print('Kopyalaniyor: ', dosya_adress)
copy2(dosya_adress, hdf)
if __name__ == "__main__":
HEDEF_KLASOR_ISIM = 'hedef_klasor'
KAYNAK_KLASOR_ISIM = "/Volumes/Time{}Machine/Backups.backupdb/Kerem’s{}MacBook{}Pro{}(2)/".format(" ", " ", " ", " ")
cwd = getcwd()
hedef_klasor = path.join(cwd, HEDEF_KLASOR_ISIM)
mkdir(hedef_klasor)
klasorleri_gez(KAYNAK_KLASOR_ISIM, HEDEF_KLASOR_ISIM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment