Tcllib 有提供 jpeg 和 exif 二個套件可以使用,因為 jpeg 有提供範例,所以最後使用 jpeg 套件來實作:
#!/usr/bin/tclsh
#
# Rename script
#
# argument 1: folder location (option)
#
package require jpeg
puts "########## Start ##########"
if {$argc >= 1} {
cd [lindex $argv 0]
} elseif {$argc == 0} {
cd "c:/tmp"
}
foreach filename [glob *.jpg] {
array set exif [::jpeg::getExif $filename]
set today [clock format [clock scan $exif(DateTimeOriginal) \
-format {%Y:%m:%d %H:%M:%S}] -format %Y%m%d]
regsub -all {\mIMG} $filename $today newFileName
file rename $filename $newFileName
}
puts "########## End ##########"
exit
相關資訊:
Wiki:Exchangeable image file format
Exchangeable image file format (Exif) is a specification for the image file format used by digital cameras. The specification uses the existing JPEG, TIFF Rev. 6.0, and RIFF WAV file formats, with the addition of specific metadata tags. It is not supported in JPEG 2000, PNG, or GIF.
沒有留言:
張貼留言