forked from hummypkg/webif
d7284ff3ef
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1016 2a923420-c742-0410-a762-8d5b09965624
79 lines
1.4 KiB
Plaintext
Executable File
79 lines
1.4 KiB
Plaintext
Executable File
#!/mod/bin/jimsh
|
|
|
|
source /mod/webif/lib/setup
|
|
require ts.class
|
|
|
|
source /mod/webif/html/dedup/normalise.jim
|
|
source /mod/webif/html/dedup/process.jim
|
|
|
|
set dirs {}
|
|
|
|
set doit 0
|
|
foreach arg $argv {
|
|
if {$arg eq "-yes"} {
|
|
set doit 1
|
|
} else {
|
|
lappend dirs $arg
|
|
}
|
|
}
|
|
if {![llength $dirs]} { lappend dirs [exec pwd] }
|
|
|
|
foreach dir $dirs {
|
|
if {[string index $dir end] eq "/"} {
|
|
set dir [string range $dir 0 end-1]
|
|
}
|
|
puts "\[$dir\]"
|
|
loadseries $dir
|
|
|
|
foreach file [readdir $dir] {
|
|
if {[file extension $file] ne ".hmt"} { continue }
|
|
|
|
set file "$dir/$file"
|
|
|
|
set base [file tail [file rootname $file]]
|
|
lassign [dedupprocess $file] stat ts syn fn
|
|
|
|
puts -nonewline "$base -> "
|
|
|
|
switch $stat {
|
|
inuse {
|
|
puts -nonewline "In Use"
|
|
}
|
|
dup {
|
|
puts -nonewline "Duplicate"
|
|
if {$doit} {
|
|
set dupdir "$dir/_duplicates"
|
|
if {![file exists $dupdir]} {
|
|
file mkdir $dupdir
|
|
}
|
|
while {[file exists $dupdir/$fn.hmt]} {
|
|
append fn "~"
|
|
}
|
|
ts renamegroup $file "_duplicates/$fn"
|
|
puts -nonewline " - Renamed to _duplicates/$fn"
|
|
}
|
|
}
|
|
error {
|
|
puts -nonewline "Cannot process"
|
|
}
|
|
nothing {
|
|
puts -nonewline "Nothing to do"
|
|
}
|
|
preserve {
|
|
puts -nonewline "Preserving"
|
|
}
|
|
ok {
|
|
puts -nonewline $fn
|
|
if {$doit} {
|
|
# Dooooo, it.
|
|
$ts settitle $syn
|
|
ts renamegroup $file $fn
|
|
puts -nonewline " ... Done"
|
|
}
|
|
}
|
|
}
|
|
puts ""
|
|
}
|
|
}
|
|
|