ADJT
Section: User Commands (1)
Updated: 2008 Feb 16
Index
Return to PGTS Main Page
NAME
adjt - Adjust timestamps in the EXIF tags of JPEG files.
SYNOPSIS
adjt
[-mto]
[-a adjust_amount]
[-d direction]
[-l lwr_bound]
[-u upr_bound]
[file1] ... [fileN]
adjt
-i [file1] ... [fileN]
adjt
-C date1 date2
DESCRIPTION
adjt
is a perl script which uses the Image::ExifTool module to process JPEG
image files. It will add or subtract an offset to the Creation Date and
the Date Digitised in a JPEG file. It can use the modification time
rather than an offset. It can also use a constant to over-write all
dates. With the -C option it can calculate the difference between two
dates. All dates are specified in the POSIX format "%Y:%m:%d %H:%M:%S"
The program updates the
DateTimeOriginal
and
CreateDate
EXIF meta tags in the JPEG file. These are sometimes referred to as the
Original Date and The Digitized Date. Whenever a file is changed by
adjt
the
ModifyDate
and file modification date will set to the current time.
FORMATS
The following formats are used for variables passed as options on the command line and set in
interactive mode.
- DATES
-
These are specified as strings in the format
yyyy:mm:dd hh:mi:ss
or
yyyy-mm-dd hh:mi:ss
or as
yyyy/mm/dd hh:mi:ss
It is also allowable to substitute an underscore for the space. So
yyyy/mm/dd_hh:mi:ss
would be a valid format. This allows the values to be passed on the command line without being
enclosed in quotes.
- ADJUSTMENTS
-
These are the amounts that are used to adjust the clock. They
can be specified with one of the five following formats:
-
- s secs
-
Seconds where
s
is a number larger than zero.
- hh:mi:ss
-
Hours, minutes and seconds. Any of these can be zero. However at least one must be non-zero.
Minutes and seconds cannot exceed 59.
- d hh:mm:ss
-
Days, hours, minutes and seconds. This is passed to the EXIF shift method as is.
- d days
-
Days.
This will be passed to the EXIF shift method as
d 00:00:00
- y years
-
Years.
This will be passed to the EXIF shift method as
y:00:00 00:00:00
OPTIONS
- -a adjust_amt
-
- --adjt-amt adjust_amt
-
Specify the adjustment amount. The
adjust_amt
is a string as specified above in the formats for ADJUSTMENTS (above).
Since these formats include a space, they should be enclosed in quotes.
It is possible to substitute an underscore for the space. In which
case these options can be specified on the command line without quotes.
An alternative way to specify the adjustment amount is with the
environment variable ADJT_ADJUSTMENT. The value specified on the command
line takes precedence over the ADJT_ADJUSTMENT variable.
- -d direction
-
- --adjt-direction direction
-
Specify the adjustment direction.
Where
direction
must be either "-1" or "+1" The -d option is mandatory if the -a
option is used. An alternative way to specify the
direction
is with the ADJT_DIRECTION environment variable.
Note:
The -d option will
over-ride the ADJT_DIRECTION variable.
- -h
-
- --help
-
Print the help screen.
- -i
-
- --info
-
Print The
Filename
and date information for the files that match the filespec. This will
show date information for these tags:
DateTimeOriginal CreateDate ModifyDate
and the pseudo-tag:
FileModifyDate
Other options will be ignored if -i is used. The only option which can
be used with this option is the -v or --verbose option, in which case
column headings will also be printed.
- -I
-
- --interactive
-
Enter interactive mode. The argument list will be processed one at a
time. Before each file is processed date information is displayed as for
the -i option (above). See below for a list of the interactive
commands.
- -l lfile
-
- --lwr-bound lfile
-
Where
lfile
is a file name in the list of files that will be the lower bound for
operations on file names that are (alphabetically) less than this name
will be removed from the argument list.
- -l ufile
-
- --upr-bound ufile
-
Where
ufile
is a file name in the list of files that will be the upper bound for
operations on file names that are (alphabetically) greater than this
name will be removed from the argument list.
- -m
-
- --mod-time
-
Use the file modification date for the Original Date.
Note:
After the modification date has been written to the Original date and
Digitized Date, the file modification date, and the internal
modification date will be updated unless the -p option is specified.
- -c timestamp
-
- --digitised-date timestamp
-
Use the specified timestamp to over-write the
CreateDate
EXIF tag.
Unless the -O option is used to specify the value for the
DateTimeOriginal
then the
DateTimeOriginal
tag will also be over-written with this value.
Timestamp format is "yyyy:mm:dd HH:MM:SS".
If the environment variables ADJT_ADJUSTMENT and ADJT_DIRECTION
have been set, the script will fail with the message:
-c cannot be specified with -a or -d
In order to prevent this, clear the two environment variables with the
commands:
export ADJT_ADJUSTMENT=""
export ADJT_DIRECTION=""
- -C
-
- --calculator-mode
-
If this option is specified,
adjt
will expect only arguments, which can be specified as
-C yyyy:mm:dd_HH:MM:SS
or
-C yyyy-mm-dd HH:MM:SS.
The difference between the two values will be calculated, and the result
will be printed to stdout in the form of an export statement for a bash
or korn shell.
- -t
-
--test
Test, do not write changes to disk. Just print to STDOUT.
- -v
-
- --verbose
-
Verbose mode. If used with the -i option, print a heading line for the
information. If used when adjusting the original date, an information
line for each file is printed to STDOUT. This would be suitable for a log.
- -b
-
backup_folder
- --backup
-
backup_folder
Move the original file to
backup_folder.
If the environment variable ADJT_BACKUP is set it will be used. The -b
option will over-ride the ADJT_BACKUP environment variable
- --done target_folder
-
- -T target_folder
-
Do not over-write original, copy to
target_folder.
If the environment variable ADJT_TARGET is set it will be used. The -T
option will over-ride the ADJT_TARGET environment variable.
- --overwrite
-
- -O
-
Overwrite target if it is exists (implies -T).
- --preserve
-
- -p
-
Preserve modification time in EXIF tag
FileModifyDate
and the (Unix) system file access and file modification times.
- --rename rename_skeleton
-
- -r rename_skeleton
-
The
rename_skeleton
must end in at least two digits.
Files in the argument list will be renamed to the skeleton sequentially.
For example, a
rename_skeleton
of xac0200 will create the file from xac0200 to xac9999. There must be
enough numbers in the sequence to rename all of the files in the
argument list.
INTERACTIVE MODE
There are two stages for interactive mode, setup and batch. When invoked with the
-I switch,
adjt
starts in the interactive setup mode.
The script will not start at all unless some image files are specified on the command line.
Interactive setup mode.
In interactive setup mode
parameters can be set for the batch.
he following is a list of
the commands that can be invoked in interactive setup mode:
- calc date1 date2
-
Where
date1
and
date2
are both date strings (see above for format).
Both the dates must be valid.
The difference is
calculated as an adjustment amount string and the parameters
adjt-amt
and
adjt-direction
are set according to the results of the calculation.
- commit
-
Commit changes to the argument list.
If the
lwr-bound
has been specified, files alphabetically less than
lfile
will be removed from the list.
If the
upr-bound
has been specified, files alphabetically greater than
ufile
will be removed from the list.
If the
reverse
option has been set the list will be reversed.
- quit
-
Cease processing and exit immediately.
- roll
-
Enter stage two (interactive batch mode).
If the there has been no previous
commit
command there will be an auto-commit before commencing to process the
roll. Stage two will adjust only the
DateTimeOriginal
EXIF tag.
- run
-
Exit from interactive mode and adjust the
DateTimeOriginal
and
CreateDate
EXIF tags, using the current parameters, as if invoked from the command
line. If the there has been no previous
commit
command there will be an auto-commit before commencing the run.
- set parm value
-
Set the value of a parameter.
The following is a list of parameters and values:
-
- adjt-amt amt_str
-
Where
amt_str
is a string specifying a clock adjustment in seconds.
See the list above for the formats.
If the
adjt-direction
parameter has not been set, it will be set to +1.
- adjt-direction direction
-
Where
direction
must be
+1
or
-1
- backup bak_folder
-
Specify the backup folder
as for the -b option above. Files will be backed up to the specified folder.
The folder must exist.
- digitised-date CreateDate
-
Set the digitised date as described for the -c option above.
The date must be valid.
- done target_folder
-
Set the
target_folder
as for the -T option above. Files will written to the specified folder.
The folder must exist.
- lwr-bound lfile
-
Set the lower bound as for the -l option above.
Files alphabetically less than this value will be removed from the argument list when
it is committed.
- mod-time ON|OFF
-
Set the
mod-time
switch as for the -m option above.
- overwrite ON|OFF
-
Set the
overwrite
switch as for the -O option above.
- preserve ON|OFF
-
Set the
preserve
switch as for the -p option above.
- rename rename_skeleton
-
Set the
rename_skeleton
as for the -r option above.
- reverse ON|OFF
-
Set the
reverse
switch as for the -R option above.
- roll
-
Exit interactive setup mode and enter interactive batch mode.
- test ON|OFF
-
Set the
test
switch as for the -t option above.
- upr-bound
-
Set the upper bound as for the -u option above.
Files alphabetically greater than this value will be removed from the argument list when
it is committed.
- verbose ON|OFF
-
Set verbosity
as for the -v option above.
This only affects the behaviour of the
run
command.
The
roll
command is not modified by the --verbose option.
- show parm
-
Show the value of a parameter. This can be one of the parameters in the above list (for the
set
command).
In addition it is possible to enter a
show
filelist
command, which will show all the files on the argument list.
Interactive batch mode.
In Interactive batch mode. A line is brought up for each file.
The following commands are available.
- r N
-
- roll N
-
The next
N
files are processed as if
Enter
had been pressed.
This can be abbreviated. For example the command
r4
would process the current file and the next three with the current
timestamp adjusted by
adjt-amt
for each iteration.
BUGS
Cannot handle timestamps outside of the Unix epoch. A later version will address this issue.
EXAMPLES
adjt -i *.jpg
List
all the files with a .jpg extension, along with the
DateTimeOriginal,
CreateDate,
ModifyDate and
FileModifyDate
Exif Tags
adjt -C 2005:07:19 21:40:06 2007:09:24 19:32:06
Calculate the difference between the two dates and print it as a value
that can be used by the
adjt
script for following operations.
In the above example
adjt
would print the following lines to the screen:
export ADJT_ADJUSTMENT="796 21:52:00"
export ADJT_DIRECTION="+1"
If the above commands are cut and pasted and then directed to a ksh or
bash shell the environment variables ADJT_ADJUSTMENT and ADJT_DIRECTION
would be correctly set for an adjustment command.
In the previous case, the following command:
adjt -t -l IMGP1142.jpg -u IMGP1197.jpg *.jpg
Would show what it would do to the timestamps in the range IMGP1142.jpg to IMGP1197.jpg.
The following command:
adjt -l IMGP1142.jpg -u IMGP1197.jpg -T processed -b done *.jpg
Would process each file with a .jpg extension in the current folder and move it to the
processed
folder. A backup
copy would be put in the
done/
folder.
FILES
/usr/local/bin/adjt
SEE ALSO
renrot(1),
perldoc
Image::ExifTool
AUTHOR
Gerry Patterson (http:/www.pgts.com.au)
HISTORY
Feb 2008 - Created after a small script, grew somewhat.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- FORMATS
-
- OPTIONS
-
- INTERACTIVE MODE
-
- BUGS
-
- EXAMPLES
-
- FILES
-
- SEE ALSO
-
- AUTHOR
-
- HISTORY
-
This document was created by
man2html,
using the manual pages.
Time: 11:11:49 GMT, March 12, 2008