Diffing directories with rsync

Caj Zell caj.zell at swipnet.se
Sat Mar 24 17:54:12 UTC 2007


Hello,

I often want to use file managers to diff/sync directories by different criteria, and I thought I'd make a personal rsync-based solution for mc that 
works to the extent that I can end up with my unique files in hierarchical order on the source side (e.g. subdir1/subdir2/file) by externally 
panelizing. The trouble is that if I want to copy that file to the target directory, it will not retain its path subdir1/subdir2/, but end up in the 
target root. My question is if there is any possibility of keeping that structure, i.e. in the above example that the directory path subdir1/subdir2/ would be 
created on the target and "file" would be placed in that location.

Details of approach:

1. In my .mc/menu:

= d D
D       Prepare diff two directories
            echo  %d %D  > .mc.dirs&     

2. In my .mc/ini

Find unique left (checksum based)=perl ~/my_own_diff.pl

where my_own_diff.pl contain


my $mc_dirs;
open($mc_dirs,"./.mc.dirs");
@dirs = split / /, (<$mc_dirs>);
#$rsync_result = `rsync  -n --out-format=\'\%n\%L\' -rtPO . ../rsynctest2/`;
$rsync_result = `rsync  -n --out-format=\'\%n\%L\' -rc $dirs[0]/. $dirs[1]`;
print $rsync_result;

3. Do an external panelize command and choose "Find unique left"


>From this example, I hope the basic idea comes forward.

What I hope to achieve by this is

1. Utilize rsyncs configuration possibilities
2. Being able to freely select which files I want to sync in subdirectories as well

Caj



More information about the mc mailing list