Yeah, it’s a good idea to do an update release. I just need to find a tool where I can easily compare current and previous release files, and create the upgrade/incremental version. There’s got to be a way to automate that right? It’s just too many changed files to keep track of manually.
There are two command line programs for this:
rsync
and
diff
. These are 2 unix (linux and macos) programs.
An example using diff
:
Code:
user@machine: $ ls ./
a b
user@machine: $ ls a
fileA.txt fileB.txt fileC.txt
user@machine: $ ls b
fileA.txt fileB.txt fileD.txt
user@machine: $ diff --brief --recursive a b
Files a/fileB.txt and b/fileB.txt differ
Only in a: fileC.txt
Only in b: fileD.txt
You can see that fileA.txt is the same, fileB.txt has changed, fileC.txt does not exist in folder
b
and fileD.txt does not exist in folder
a
.
--brief will make the output only show one line for each file that has a change, instead of showing all the changes for each file.
--recursive will allow it to also dive into subfolders (although my example has no subfolders).
A shorter form is
diff -qr a b
You could use
grep
to print only the lines that has "differ", or only the lines that has "Only in a:" or "Only in b:".
Code:
user@machine: $ diff --brief --recursive a b | grep "differ"
Files a/fileB.txt and b/fileB.txt differ
user@machine: $ diff --brief --recursive a b | grep "Only in a:"
Only in a: fileC.txt
user@machine: $ diff --brief --recursive a b | grep "Only in b:"
Only in b: fileD.txt
An example using rsync
:
Code:
user@machine: $ ls
a b c
user@machine: $ ls a
fileA.txt fileB.txt fileC.txt
user@machine: $ ls b
fileA.txt fileB.txt fileD.txt
user@machine: $ ls c # empty
user@machine: $ rsync -vcrP --stats --compare-dest=../a/ ./b/ ./c/
sending incremental file list
fileB.txt
30 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=1/4)
fileD.txt
19 100% 18.55kB/s 0:00:00 (xfr#2, to-chk=0/4)
Number of files: 4 (reg: 3, dir: 1)
Number of created files: 1 (reg: 1)
Number of deleted files: 0
Number of regular files transferred: 2
Total file size: 56 bytes
Total transferred file size: 49 bytes
Literal data: 49 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 295
Total bytes received: 55
sent 295 bytes received 55 bytes 700.00 bytes/sec
total size is 56 speedup is 0.16
user@machine: $ ls c
fileB.txt fileD.txt
The slashes after each folder name is important. The dot slash before each folder name is also important.
flag -v and -P and --stats only makes it print a bunch of stuff on screen. flag -c makes rsync compare files by checksum. flag -r makes it dive into subfolders. --compare-dest is the folder, which path is relative to being inside folder
c
, that has the inital state for files and subfolders.
b
is the folder that has the final state for files and subfolders.
c
is the folder where the changes will be placed, leaving folder
a
intact.
In other terms, it calculates a delta of files which is
b
MINUS
a
, which RESULTS in the things that
b
has but
a
doesn't.
The things that
a
has but
b
doesn't, are ignored, so you won't have them listed.
This is good to make differential zip files for updates. The only downside, is that those differentials won't hold the information regarding the deleted files, because they only have what is new. So a person downloading these differential zip files, will have all the new files plus all the delete/unused ones in their computer.
You could make a script to delete all the unused files (you can see a list of them by issuing:
diff -qr a b | grep "Only in a:"
), and make it available for the user to run, if they wanted to. But windows scripts and unix scripts use different syntax, so you would have to make 2 available. I could help you with that. Or you just give the list of deleted files and the user could delete them with their own hands.