ODF oops

Q I have a huge number of OOo files with meaningless filenames. I need to sort out those that have been created or modified in the last month, but all the files have the same timestamps. I hoped that Konqueror's Info List View would help, as it does for Exif info in JPEG files, but it doesn't give any columns apart from file name, even though the metadata is present on the mouseover tooltip.

A If these are in Open Document Format, the process is surprisingly easy. ODF files are Zip archives containing several files that comprise the document and its metadata. Even if you rename the ODF file, the timestamps of the files within it remain unchanged. Because of this, it's possible to extract a file from each ODF archive and set the archive's timestamp to match that file. A short shell loop will update all the files in a given directory

for f in *.ods *.odt
do
unzip -o "$f" content.xml && touch -r content.xml "$f" && rm -f content.xml
done

This loops through each ODS and ODT file, extracting the content.xml file. If that is successful, it uses that as the reference for touch to set the modification date of the original file, then removes the content.xml file.

Back to the list