Friday, October 29, 2010

Script to remove tailing "(00)" in filenames

#!/usr/bin/tclsh

foreach f [glob *.*] {
    if {[regexp -all -nocase {(.*)\.(.*)} $f dummy fullname ext] } {
        if { [regexp -all -nocase {(.*)\(00\)} $fullname dummy name ] } {
             set cmd "file rename -force \"$f\" \"$name.$ext\""
             puts $cmd
             eval $cmd
        }
    }
}

1 comment:

  1. A better approach:

    regsub -all -nocase {\(00\)} $f "" cleanf

    ReplyDelete