#!/mod/bin/jimsh package require cgi source /mod/var/mongoose/lib/setup require ts.class pretty_size altrow puts "Content-Type: text/html" puts "" cgi_input #cgi_dump set dir [cgi_get dir "/media/My Video"] set doit [cgi_get doit 0] # Strip double slashes header puts "
De-duplicate $dir " regsub -all -- {\/+} "$dir/*" "/" dir foreach file [lsort [glob -nocomplain "$dir"]] { if {[file extension $file] ne ".hmt"} { continue } altrow set ts [ts fetch $file 1] set base [file tail [file rootname $file]] puts "" set syn [$ts get synopsis] regsub -nocase -all -- {^new series\.* *} $syn "" syn regsub -all -- { *[:].*$} $syn "" syn if {[string length $syn] > 40} { regsub -all -- { *[\.].*$} $syn "" syn } if {[string length $syn] < 6} { append syn " [$ts get title]" } regsub -all -- {[\/ &]} $syn "_" fn puts "" puts "" puts "" puts "" } puts {
File Proposed Filename Proposed Title Status
$base$fn$syn" if {[file exists "$dir/$fn.hmt"]} { puts "Duplicate" } elseif {[string length $syn] > 40} { puts "Cannot process" } elseif {$base eq $fn} { puts "Already done" } elseif {$doit} { # Dooooo, it. $ts settitle $syn $ts renamegroup $file $fn puts "Done" } puts "
} if {!$doit} { puts "" } puts {
" footer