Monday, January 3, 2011

tcl programming fun rename all vids ina folder to 1..500

assume a folder full of movies downloaded using opera browser
3_5.mpg 2_3.mpg etc etc

task: end up with movies numbered 1.mpg 2.mpg .. 500.mpg so you can watch in order without forgetting which one you last watched.

$ cat num.tcl
#!/usr/bin/tclsh
set dir {/home/g/etc/v}
set movies [glob $dir/*]
set x 1000000
foreach y ${movies} {
file rename $y $dir/$x.mpg
incr x
}
set movies [glob $dir/*]
set x 1
foreach y ${movies} {
file rename $y $dir/$x.mpg
incr x
}

No comments: