Useful common Unix commands and tricks
ln -s -T ~/Software/GitAhead/GitAhead ~/.bin/gitahead
To use a physical link instead of a symlink, use -S
instead of -s
sudo tar --create --gzip --file bck_var_log.tgz --verbose /var/log
systemctl list-units --state=failed
Let's assume different people took pictures with format like IMG_YYYYMMDD_hhmmss[suffixe].jpg
e.g. IMG_20220713_210605__01.jpg
.
If you want to mix photos while keeping chronological order in viewers, you have to rename them in order to sort them alphabetically by date.
Use the command below to make every file start by YYYYMMDD_hhmmss
.
Replace firstname
by the firstname of the person taking the picture.
exiftool -p 'mv $FileName ${CreateDate}_firstname.jpg' -d "%Y%m%d_%H%M%S" -q
. > rename.sh
exiftool -p 'heif-convert $FileName ${CreateDate}_firstname.jpg' -d "%Y%m%d_%H%M%S" -q *.HEIC >> rename.sh
Then execute and remove rename.sh
.
Some phones use HEIC, that's a weird closed format. To convert them, two ways (use the one which works) :
convert 20240816_194033.heic 20240816_194033_user.jpg
sudo apt install libheif-examples
heif-convert -q 85 20240816_194033.heic 20240816_194033_user.jpg
On Ubuntu, you have two different utilities : rename.ul
making simple replacements, and rename
working with regex.
p1.jpg
-> p1_suffixe.jpg
rename.ul '.jpg' '_suffixe.jpg' *
20220711_181620~2.jpg
-> 20220711_181620_2.jpg
rename.ul '~' '_' *.jpg
rename.ul ')' '' *.jpg
rename.ul '(' '_' *.jpg
CANON_20220711_181620.jpg
-> 20220711_181620_IMG_CANON.jpg
rename 's/(\w+)_(\d{8}_.*)\./$2_IMG_$1./' *.jpg
CANON_IMG_20220713_210605__01.jpg
-> 20220713_210605__01_IMG_CANON
SAM_VID_20220713_210605__01.mp4
-> 20220713_210605__01_VID_SAM.mp4
rename 's/(\w+)_(\w{3})_(\d{8}_.*)\./$3_$2_$1/\.' *
rename 's/(^PXL_.*_[0-9]{6}).*\.jpg$/$1_IMG_person.jpg/' *.jpg
rename 's/(^PXL_.*_[0-9]{6}).*\.mp4$/$1_IMG_person.mp4/' *.mp4
rename.ul -- 'PXL_' '' *
Take care, timestamp seems to be in UTC.