forked from hummypkg/webif
909342eb1c
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1402 2a923420-c742-0410-a762-8d5b09965624
49 lines
986 B
Plaintext
Executable File
49 lines
986 B
Plaintext
Executable File
#!/mod/bin/jimsh
|
|
|
|
package require cgi
|
|
source /mod/webif/lib/setup
|
|
require ts.class
|
|
|
|
httpheader
|
|
|
|
set file [cgi_get renamefile "-"]
|
|
if {$file eq "-"} exit
|
|
|
|
set newfile [string trim [cgi_get rename]]
|
|
set dir [file dirname $file]
|
|
|
|
if {[file isdirectory $file]} {
|
|
#puts "Directory."
|
|
if {$newfile ne ""} {
|
|
set newfile "${dir}/${newfile}"
|
|
file rename $file $newfile
|
|
}
|
|
} elseif {[set ts [ts fetch $file]] != 0} {
|
|
#puts "TS file."
|
|
|
|
foreach attr {title synopsis guidance genre} {
|
|
if {[catch {
|
|
set new [string trim [cgi_get "rename_$attr"]]
|
|
set old [$ts get $attr]
|
|
if {$new ne $old} {
|
|
if {$attr eq "guidance" ||
|
|
[string length $new] > 0} {
|
|
$ts set$attr $new
|
|
}
|
|
}
|
|
} msg]} {
|
|
puts "$attr: $msg"
|
|
}
|
|
}
|
|
|
|
if {"$dir/$newfile.ts" ne "$file"} { ts renamegroup $file $newfile }
|
|
} else {
|
|
#puts "Normal file."
|
|
if {$newfile ne ""} {
|
|
set newfile "$dir/$newfile[file extension $file]"
|
|
puts "Rename ($file) -> ($newfile)"
|
|
file rename $file $newfile
|
|
}
|
|
}
|
|
|