-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmd5-recursive
More file actions
21 lines (17 loc) · 804 Bytes
/
md5-recursive
File metadata and controls
21 lines (17 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
## useful for cases where different file structures exist between machines
# md5 recursive on linux
### source: https://askubuntu.com/a/907955/420815
find . -type f -exec md5sum '{}' \; > md5sum1.txt
# md5 recursive on macOS
find . -type f -exec md5 -r '{}' \; > md5sum2.txt
# compare files
## read files into dictionary - python
remote = {line.split()[0]: line.split()[1] for line in open("md5sum1.txt")}
local = {line.split()[0]: line.split()[1] for line in open("md5sum2.txt")}
## get files that are different on the remote - python
filelist = [remote[key] for key in set(remote).difference(set(local))]
with open("filesonremote.txt","w") as outfile:
for item in filelist:
outfile.write("{}\n".format(item))
# copy files
rsync -auvP --files-from=filesonremote.txt server:/pathtodir/ .