hsync: renamed syncer to hsync, + a few bug fixes

master
Pierre Neidhardt 2013-11-12 13:41:08 +01:00
parent 94a52fa46a
commit 2ca9e82109
2 changed files with 22 additions and 13 deletions

View File

@ -98,7 +98,7 @@ auto-resize-window=false
zoom-step=0.10 zoom-step=0.10
default-font-family=sans-serif default-font-family=sans-serif
ssl-untrusted-color=#ff0000 ssl-untrusted-color=#ff0000
plugin-blocker=false plugin-blocker=true
startpage=dwb:bookmarks startpage=dwb:bookmarks
normal-completion-bg-color=#151515 normal-completion-bg-color=#151515
cursive-font-family=serif cursive-font-family=serif

View File

@ -1,10 +1,11 @@
#!/bin/awk -f #!/bin/awk -f
function _printhelp() { function _printhelp() {
print "Usage: " ARGV[0] "[-vr=1] SOURCE TARGET" print "Usage: hsync [-vr=1] SOURCE TARGET\n"
print "\nMove files in TARGET identical to files in SOURCE such that they follow the same hierarchy." print "Filesystem Hierarchy synchronizer."
print "\nSymlinks are ignored." print "Move files in TARGET identical to files in SOURCE such that they follow the same hierarchy."
print "\nSet 'r' to 1 to actually run the process." print "Symlinks are ignored."
print "Set 'r' to 1 to actually run the process."
} }
BEGIN { BEGIN {
@ -50,7 +51,7 @@ BEGIN {
target[sum]=$0 target[sum]=$0
} }
print "\n==> Syncing from " ARGV[1] " to " ARGV[2] print "\n==> Syncing hierarchy from " ARGV[1] " to " ARGV[2]
for (i in target) for (i in target)
{ {
split(i, subi, SUBSEP) split(i, subi, SUBSEP)
@ -59,14 +60,22 @@ BEGIN {
dirname=source[subi[1]] dirname=source[subi[1]]
sub(/[^/]+$/, "", dirname) sub(/[^/]+$/, "", dirname)
## We only create a new folder if necessary. ## Target -> Source
if (dirname) change="'" ARGV[2] "/" target[subi[1]] "' '" ARGV[2] "/" source[subi[1]] "'"
cmd="mkdir -p " ARGV[2] "/" dirname " && mv " ARGV[2] "/" target[subi[1]] " " ARGV[2] "/" source[subi[1]]
else
cmd="mv " ARGV[2] "/" target[subi[1]] " " ARGV[2] "/" source[subi[1]]
print cmd ## We only create a new folder if necessary.
if (run) cmd="[ ! -d '" dirname "' ] && mkdir -p \"" ARGV[2] "/" dirname "\" && mv -n " change
# if (dirname)
# {
# print "### NARJ"
# cmd="[ ! -d ] \'" dirname "\' && mkdir -p \"" ARGV[2] "/" dirname "\" && mv -n " change
# }
# else
# cmd="mv -n " change
## TODO: sort preview.
print change
if (r)
system(cmd) system(cmd)
} }
} }