After the last lugod meeting, Tim asked about a way to "sync" a target directory with some source directory. While most everyone suggested rsync was the way to go, Tim didn't like rsync because it would take "too long". In Tim's case the primary way he modifies the source data set is to rename files or directories. Rsync would consider those renames that to be a delete old and add new, instead of a "rename".
=== Anyway, if I remember the problem description correctly Tim was certain that files would only be changing on the source drive, if they changed four things could happen: - A file could Move from one location to another. - A dir could Change names. - A file/dir could be Added. - A file/dir could be Removed. Files would Never be Changed. === So anyway... I thought this was interesting enough http://simons-clan.com/~msimons/perl/push_tree [EMAIL PROTECTED]:~/perl$ ./push_tree -vn ./source ./dest/ === make directory ./dest/dir1/ make directory ./dest/dir2/ move file ./dest/file1 to ./dest/dir2/file1 copy file ./source/dir2/file to ./dest/dir2/file move file ./dest/old.dir1/old.zap to ./dest/dir1/zap move file ./dest/old.dir1/zip to ./dest/dir1/zip nuke file ./dest/nuke1 nuke directory ./dest/ndir1/ nuke directory ./dest/old.dir1/ === The script supports two options: -n : don't really change anything -v : print out what you plan to do The script requires two arguments: <source_dir> <target_dir> The script does three things badly: - target directory missing. - uses "cp -p" instead of opening file inside perl - renamed directories result in a mkdir, rename of each file, rmdir; instead of one rename. The way it operates is to index source and target directories building a hash for each dir of file = timestamp/size, dir = timestamp. Then loops over the two has a few times... applying changes in the order they make sense. _______________________________________________ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech