Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #mappa tartalmat kilistázza méret és dátum adatokkal együtt txt file-ba
- import os, datetime
- foldername = input("Enter the folder name:") #csak pontos útvonal adható!
- folderPath = foldername
- # string változó előkészítése
- finalText = ""
- if os.path.exists(folderPath):
- filelist = os.listdir(folderPath)
- for i in filelist:
- size = int((os.path.getsize(folderPath + "/" + i))/1024) #csak mappa méret tartalom nélkül?
- creation_date = datetime.datetime.fromtimestamp(os.path.getctime(folderPath + "/" + i))
- # itt adjuk hozzá a finalText-hez
- finalText += "File: {}, \tSize: {} kB, \tCreation date: {}\n".format(i, size, creation_date)
- else:
- print("no results")
- # ezt jobb egyben kiírni ha megvan a finalText
- with open(folderPath + "/filelist.txt", "w") as f:
- f.write(finalText)
- # elég csak a string-et printelni
- print(finalText)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement