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
default-font-family=sans-serif
ssl-untrusted-color=#ff0000
plugin-blocker=false
plugin-blocker=true
startpage=dwb:bookmarks
normal-completion-bg-color=#151515
cursive-font-family=serif

View File

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