-
Notifications
You must be signed in to change notification settings - Fork 0
/
Filelist backupper.py
32 lines (23 loc) · 1.01 KB
/
Filelist backupper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import json
from getFileInfo import getFileInfo
print("Running...")
f = open("Filelist backupper configuation.txt", "r") #Config filename
config = json.loads(f.read()) #The config file format is json like, { "directories": ["Documents", "Pictures", "Videos"], "ignoreFileNames": ["desktop.ini"], "blockSize": 512 }
f.close()
directories = config["directories"] #Just an array of directory name strings
ignoreFileNames = config["ignoreFileNames"] #An array of filenames to ignore
blockSize = config["blockSize"]
filesAndInfo = []
for parentDirectory in directories:
for path, subdirs, files in os.walk(parentDirectory):
for name in files:
if name not in ignoreFileNames:
fileInfo = getFileInfo(name, path, parentDirectory, blockSize)
filesAndInfo.append(fileInfo)
print(str(len(filesAndInfo)) + " files")
filesInfoJsonString = json.dumps(filesAndInfo)
f = open("files info for backup.txt", "w")
f.write(filesInfoJsonString)
f.close()
print("Done.")