From c8323579a2d13fda159f13797b9934fff939bb2a Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 13 Oct 2024 20:45:50 +0200 Subject: [PATCH] chore(kb): improve tagging-related commands --- knowledge base/exiftool.md | 65 +++++++++++++++++++++++++++++++------- knowledge base/getfattr.md | 17 ++++------ knowledge base/touch.md | 12 +++++-- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/knowledge base/exiftool.md b/knowledge base/exiftool.md index 3d73cb1..432ca4f 100644 --- a/knowledge base/exiftool.md +++ b/knowledge base/exiftool.md @@ -1,42 +1,85 @@ # ExifTool -Platform-independent Perl library and command-line application for reading, writing and editing meta information in a wide variety of files.
+Platform-independent Perl library and command-line application for reading, writing and editing meta information in a +wide variety of files.
It supports many different metadata formats as well as the maker notes of many digital cameras. -## Table of contents - 1. [TL;DR](#tldr) 1. [Further readings](#further-readings) -1. [Sources](#sources) + 1. [Sources](#sources) ## TL;DR +
+ Setup + ```sh # Installation. brew install 'exiftool' +sudo zypper in 'exiftool' ``` +
+ +
+ Usage + +```sh +# Show metadata in files. +exiftool 'path/to/image-1.jpg' 'path/to/image-n.jpg' + +# Only show specific metadata tags. +# Tags selection is case *in*sensitive. +# Spaces in tags must be removed from the selector. +exiftool -'tagName' 'path/to/image-1.jpg' + +# Add or edit metadata tags. +exiftool -author='linuxConfig' -title='Linux penguin' 'image.jpg' + +# Remove metadata tags. +exiftool -author='' -title= 'image.jpg' +exiftool -all='' 'image.jpg' +``` + +
+ +
+ Real world use cases + +```sh +# It would be the same to use '-imageheight', '-ImageHeight' or '-imageHeight'. +exiftool -ImageHeight 'Downloads/meme.png' + +# Print formatted date/time for all JPG files in the current directory. +exiftool -d "%r %a, %B %e, %Y" -DateTimeOriginal -S -s *'.jpg' + +# Extract all GPS positions from an AVCHD video. +exiftool -ee -p "$gpslatitude, $gpslongitude, $gpstimestamp" 'a.m2ts' + +# Recursively extract JPG images from Canon CRW files in the current directory. +# Add 'C<_JFR.jpg>' to the name of the output JPG files. +exiftool -b -JpgFromRaw -w '_JFR.jpg' -ext 'CRW' -r '.' +``` + +
+ ## Further readings - [Website] - [Github] -## Sources - -All the references in the [further readings] section, plus the following: +### Sources - [Top 5 ways to view and edit metadata] [github]: https://github.com/exiftool/exiftool [website]: https://exiftool.org/ - -[further readings]: #further-readings - [top 5 ways to view and edit metadata]: https://daminion.net/articles/tips/top-5-ways-to-view-and-edit-metadata/ diff --git a/knowledge base/getfattr.md b/knowledge base/getfattr.md index 98036c3..96bcca1 100644 --- a/knowledge base/getfattr.md +++ b/knowledge base/getfattr.md @@ -1,10 +1,8 @@ # `getfattr` -## Table of contents - 1. [TL;DR](#tldr) 1. [Further readings](#further-readings) -1. [Sources](#sources) + 1. [Sources](#sources) ## TL;DR @@ -13,6 +11,9 @@ apt install 'attr' dnf install 'attr' +# Get values for all attributes. +getfattr -d 'path/to/file.1' … 'path/to/file.N' + # Get values for specific extended attributes. getfattr -n 'name' 'path/to/file.1' … 'path/to/file.N' ``` @@ -21,20 +22,16 @@ getfattr -n 'name' 'path/to/file.1' … 'path/to/file.N' - [`setfattr`][setfattr] -## Sources - -All the references in the [further readings] section, plus the following: +### Sources - [`man` page][man page] - [Tag files in GNU/Linux] - -[further readings]: #further-readings - [setfattr]: setfattr.md [tag files in gnu/linux]: tag%20files.md diff --git a/knowledge base/touch.md b/knowledge base/touch.md index ec623ab..1a6ff9b 100644 --- a/knowledge base/touch.md +++ b/knowledge base/touch.md @@ -1,7 +1,5 @@ # The `touch` command -## Table of contents - 1. [TL;DR](#tldr) ## TL;DR @@ -11,4 +9,14 @@ # End the time with 'Z' to specify the new time is UTC instead of local time. touch -cd '2017-08-15T13:28:42' '20170815_132842.mp4' touch -cd '2017-08-15T12:28:42Z' '20170815_132842.mp4' + +# Change only the access time. +touch -ca -t '201801211200.10' 'file.txt' +touch -c --time=access -t '201801211200.10' 'file.txt' +touch -c --time=atime -d '2018-01-21T12:00:10' 'file.txt' + +# Change only the modification time. +touch -cm -t '201611161200.10' 'file.txt' +touch -c --time=modify -t '201611161200.10' 'file.txt' +touch -c --time=mtime -d '2016-11-16T12:00:10' 'file.txt' ```