The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

keeptime - wraps other command-line tools to keep or carry-over file timestamps

SYNOPSIS

        $ keeptime mogrify -format jpg image.png

DESCRIPTION

A file's modification timestamp is an important piece of metadata. Mostly it's used in lieu of crtime and tells you when a file was created or downloaded. Sometimes files need a final touch-up, an alteration that is marginal, a measure of optimisation or error fixing. This kind of marginal edit is not meant to alter the timestamp.

Many CLI tools like imagemagick's convert or mogrify, the jpegtran tool or ffmpeg (avconv) are handy to change what's in a file or how. For example you might convert png images to jpg, or a wav file to mp3. But most tools miss an option to keep the timestamps of the original file, in case they transform in-place, or to carry over these timestamps to the new target file. (Well, optipng offers the -preserve switch and mp3gain -p, to name just two notable exceptions.)

Anyway, so far, you had to employ a two-step process to keep (or restore) original timestamps. You did the alterations/transcodes and then executed "touch -d" to adjust the file's mtime timestamp to that of the original source. Annoying, especially if the original file was altered in-place. Then it was actually a three-step process, with you noting down the original timestamp in the first place.

keeptime is meant as a wrapper that does just that in one go: it notes down the mtime of the original (source) file and after the wrapped command has exited, it adjusts the timestamp of an in-place edited or newly created output (target) file to equal the timestamp of the original (source) file.

The ideas is this:

        keeptime stats source-file/original
         (wrapped tool runs)
        keeptime adjusts timestamp of target-/edited-file

One usage scenario would be to wrap keeptime around commands you execute via Nautilus Actions:

Cropped screenshot of having keeptime as option in Nautilus Actions' context menu

CAVEATS

This is alpha stage software! Be careful when you use it. Look into the source to understand what it does and to make sure that it's safe for you to use. And feel free to send patches or improvements by forking the public repository.

Syntax recognition is very limited at this time. So far, keeptime only recognises leafpad, mogrify and cropgui.

TODO

A file's mtime is only one metadata attribute probably worth carrying over. So this here might eventually evolve into keep(m)time and a yet to write keepattr. Or an even more general tool to preserve a selection of file-internal and file-external attributes, coming from stat, from extended file attributes, APP1 segments in JPEGs (like Exif and XMP), MP4 metadata or ID3 tags.

AUTHOR

Clipland GmbH http://www.clipland.com/

COPYRIGHT & LICENSE

Copyright 2013 Clipland GmbH. All rights reserved.

This library is free software, dual-licensed under GPLv3/AL2. You can redistribute it and/or modify it under the same terms as Perl itself.