-
Notifications
You must be signed in to change notification settings - Fork 0
/
automtime.1
278 lines (278 loc) · 6.58 KB
/
automtime.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
.\" -*- nroff -*-
.TH AUTOMTIME 1 "2024-01-10" "automtime version 8-dev"
.SH NAME
automtime \- automatically extract modification times from files
.SH SYNOPSIS
.B automtime
[
.B \-l
]
[
.B \-m
]
[
.B \-e
program ]
[
.B \-q
]
[
.B \-t
type ]
file1
[
.I file2 ...
]
.SH DESCRIPTION
.B automtime
attempts to extracts metadata about the last modification time of a file from
the internal contents of the file data. Many file formats contain provision for
storing metadata such as the last time a file was saved within the contents of
the file's data. This is entirely separate from the modification time stored on
the filesystem and automatically updated by the OS when a file is updated.
.LP
The file names and times are output on stdout by default, using
shell-compatible quoting for each. Using the \-e option, they can also be used
as arguments to an optional user-defined program called for each file, which
can be used to update the modification time of the file on the filesystem or
any other function.
.LP
Many file formats require a special program to extract the metadata. If the
required program is not found, an error message like \(lqcommand not found\(rq
is displayed.
.LP
Sometimes, for some formats, embedded dates don't represent the true mtime of a
file. For example, an image might contain the date it was taken but not the
date it was edited on a computer. The user should consider the meanings and
limitations of embedded date and times when choosing to use them.
.LP
It currently supports the following file types:
.LP
.RS
.\" This section comes from: ./automtime -l | sed -e a.LP -e 's/^\./\\\&./'
7zip (7zip archive)
.LP
abw (AbiWord document)
.LP
amf (Additive Manufacturing File)
.LP
appdata (Appdata metainfo file)
.LP
ar (ar archive)
.LP
arj (arj archive)
.LP
cab (Microsoft Cabinet archive)
.LP
cpio (CPIO Archive)
.LP
cpiogz (gzip-compressed CPIO Archive)
.LP
dar (Disk Archiver archive)
.LP
dat (Allegro4 not packed datafile)
.LP
dll (Microsoft Windows PE dynamic link library)
.LP
docbook (DocBook document)
.LP
docx (Microsoft Office Open XML)
.LP
email (E-mail or similar message)
.LP
exe (Microsoft Windows PE executable)
.LP
fodf (Open Document Format flat file)
.LP
gcode (G-code machine control file)
.LP
gnumeric (Gnumeric spreadsheet)
.LP
gpx (GPX GPS track)
.LP
gzip (gzip-compressed file)
.LP
ics (iCalendar file)
.LP
ipk (Itsy package)
.LP
iso (ISO-9660 CD-ROM image)
.LP
jpeg (JPEG JFIF image)
.LP
kra (Krita image)
.LP
lzh (lzh archive)
.LP
lzo (lzo archive)
.LP
mkv (Matroska video)
.LP
mov (QuickTime video)
.LP
odf (Open Document Format)
.LP
otf (OpenType font/TrueType font)
.LP
patch (unified diff style patch)
.LP
pbi (PC-BSD package)
.LP
pcap (Pcap network capture file)
.LP
pdf (Portable Document Format)
.LP
png (PNG image)
.LP
ps (PostScript)
.LP
rar (rar archive)
.LP
rpm (rpm package)
.LP
rtf (Rich Text Format file)
.LP
shar (shell archive)
.LP
sla (Scribus document)
.LP
slob (Sorted List of Blobs dictionary)
.LP
squashfs (Squashfs filesystem image)
.LP
svg (Scalable Vector Graphics image)
.LP
tar (Tape Archive)
.LP
tbz (Bzip2-compressed Tape Archive)
.LP
tgz (Gzip-compressed Tape Archive)
.LP
tiff (TIFF image)
.LP
tlzip (Lzip-compressed Tape Archive)
.LP
tlz (Lzma-compressed Tape Archive)
.LP
txz (Xzip-compressed Tape Archive)
.LP
tzst (Zstd-compressed Tape Archive)
.LP
vbox (VirtualBox machine file)
.LP
warcgz (Compressed Web Archive Collection file)
.LP
wml (Wireless Markup Language)
.LP
xcf (Gimp image)
.LP
zip (zip archive)
.LP
zpaq (ZPAQ compressed archive)
.LP
.\" End of mechanically-generated section
.RE
.\" ---------------------------------------------------------------------------
.SH OPTIONS
.TP
.BI \-e \ program
Run
.I program
once for each file. It is given two arguments; the file time and the file
name. The program argument is subject to shell quoting so it can contain
multiple words.
.TP
.B \-l
List the types of files supported. The first word of each line is the type to
give the \-t option. Some types are actually families that support several file
extensions.
.TP
.B \-m
Set the mtime of the file on the filesystem to its embedded mtime. This is
equivalent to setting
.B \-e 'touch -d'.
.TP
.BI \-t \ type
Use
.I type
as the file type instead of determining it from the file name. The value of
.I type
must come from the list shown with \-l.
.TP
.B \-q
Set quiet mode. Don't display anything except in case of error.
.\" ---------------------------------------------------------------------------
.SH EXAMPLES
To see the save time of the PDF file
.IR foo.pdf ,
run:
.EX
automtime foo.pdf
.EE
.LP
To see only the files with embedded times that can be extracted, run:
.EX
automtime * 2>/dev/null
.EE
.LP
If the file
.IR foo.otf
is actually an OpenText file (and not an OpenType font file) run:
.EX
automtime -t odf foo.otf
.EE
.LP
If the file
.I foo.png
contains an embedded modification time of Mon, 11 Oct 2021 12:34:56 +0000 then
this command would change the mtime of the file in the filesystem:
.EX
automtime -e 'touch -d' foo.png
.EE
This would end up running the command
.EX
touch -d 'Mon, 11 Oct 2021 12:34:56 +0000' foo.png
.EE
The \-m option is a shortcut for setting this.
.LP
This command would rename all the PDF files to their modification times with a
.I .pdf
extension:
.EX
automtime -e 'renuniq -t %{DESC}%{EXT} -d' *.pdf
.EE
This relies on the
.I renuniq
program from https://github.com/dfandrich/renuniq/
.\" ---------------------------------------------------------------------------
.SH "EXIT STATUS"
.B automtime
always returns 0 unless no arguments were given when it returns 1. This is
subject to change in a future release.
.\" ---------------------------------------------------------------------------
.SH BUGS
.BR automtime 's
command-line option processing is very limited; the order which options appear
is significant and only one option may follow each dash. Its comment extraction
is in some cases built around a simple regex that may be easily fooled.
.LP
The POSIX helper programs needed to process some file types (such as
.BR date (1))
are expected to support GNU extensions and may not produce the expected results
otherwise. An automatic fallback is provided for
.B date
that works as well for many types but it requires that the nonstandard Python
.I dateutil.parser
and
.I pytz
modules be installed.
.\" ---------------------------------------------------------------------------
.SH AUTHOR
Daniel Fandrich <dan@coneharvesters.com>
.LP
See https://github.com/dfandrich/fileviewinfo/
.\" ---------------------------------------------------------------------------
.SH COPYRIGHT
.B automtime
is Copyright (c) 2023\(en2024 Dan Fandrich <dan@coneharvesters.com>.
Licensed under the MIT license (see LICENSE).