I'm still learning scripting and need some direction on modifying time/date strings.
Some background, I learned early on that most unix/linux file system don't track the file creation date/time but it doesn't matter anyway since something as simple as e-mailing a file invalidates it. I learned about metadata inside files such as the jpg exif and similar. Now I keep a lot of information electronic and sometimes have to scan things and am working on using the metadata to track some info about what I've scanned. This leads me to todays script.
Using xscanimage I get a .pnm which I convert to a .tif then add in the metadata with a script something like this:
exiftool -IFD0:ModifyDate="2009:02:11 22:24:14" *.tif
exiftool -IFD0:ImageDescription="Receipt" *.tif
Now I'm trying to automate this a bit more by taking from the konqueror service menu for the convert to .tif I make my script
convert %f "`echo %f | perl -pe 's/\.[^.]+$//'`.tif"
I want to take the output of
which looks like
2009-02-11 22:24:14.000000000 -0500
and feed it into the command
exiftool -IFD0:ModifyDate="2009:02:11 22:24:14" %f.tif
So what happens is the original .pnm gets a time and date set on the file system when its written by xscanimage. I then use the script called by the Konqueror service menu which converts to .tif and in addition take the file system date/time and feeds it into exiftool to set it in the file's metadata therefore preserving it.
My difficulty lies in converting the format of the time and date from the output of one to the proper format for the other and passing the variable through as I don't sting stat will take %f like the original service menu script did since stat uses % as its option delimiter.
Of course any suggestions of other tools that may do this easier will help too. I'm setting more than just the time/date, I set other fields that save things like the scanner make and model, and descriptions. For example I have a IRA account that the bank doesn't allow electronic statements so I have to scan the paper ones. I then put what they are in the descriptions.
I use the same for my pictures, instead of trying to rename 100 .jpg's from a family vacation I used exiftool and wildcards to edit comments into several at once.