#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require ts.class pretty_size altrow
header
source normalise.jim
source process.jim
set dir [cgi_get dir "/media/My Video"]
set doit [cgi_get doit 0]
puts ""
puts "
De-duplicate $dir
File
Proposed Filename
Proposed Title
Status
"
loadseries $dir
set recalc 0
foreach file [readdir $dir] {
set file "$dir/$file"
if {[file extension $file] ne ".hmt"} { continue }
set base [file tail [file rootname $file]]
lassign [dedupprocess $file] stat ts syn fn
altrow
puts "$base "
puts "$fn "
puts "$syn "
puts ""
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"
incr recalc
}
}
error {
puts -nonewline "Cannot process"
}
nothing {
puts -nonewline "Nothing to do"
}
preserve {
puts -nonewline "Preserving"
}
ok {
if {$doit} {
# Dooooo, it.
$ts settitle $syn
ts renamegroup $file $fn
$ts set_deduped
puts -nonewline "Done"
}
}
}
puts " "
puts ""
}
if {$recalc} { ts resetnew $dir }
puts {
Back to media browser
}
if {!$doit} { puts "Process folder " }
puts {
}
footer