Skip to content

Instantly share code, notes, and snippets.

View dixonge's full-sized avatar

Glenn Dixon dixonge

View GitHub Profile
@dixonge
dixonge / Rename-photos-name-original-date-timestamp
Last active April 2, 2020 16:51
Rename photos with name followed by original file date/timestamp using exiftool
exiftool '-filename<file-name-text-goes-here-$CreateDate' -d %Y-%m-%d_%H-%M-%S%%-c.%%le *.jpg
@dixonge
dixonge / Set-photo-title-description-exiftool
Created April 2, 2020 16:49
Set photo title and description with exiftool
exiftool -title='Title goes here' -description='Description goes here' .
@dixonge
dixonge / Kernel-customization-Elan-touchpad-Lenovo-Ideapad-330-Ubuntu18.04
Created April 2, 2020 16:48
Kernel customization to enable Elan touchpad on Lenovo Ideapad 330 w/ Ubuntu 18.04
#ifdef CONFIG_ACPI static const struct acpi_device_id elan_acpi_id[] = {
{ "ELAN0000", 0 },
{ "ELAN0100", 0 },
{ "ELAN0600", 0 },
{ "ELAN0602", 0 },
{ "ELAN0605", 0 },
{ "ELAN0608", 0 },
{ "ELAN0609", 0 },
{ "ELAN060B", 0 },
{ "ELAN060C", 0 },
@dixonge
dixonge / Extract-Title-Description-from-flickr-json
Created April 2, 2020 16:46
Extract Title and Description from json file and write it to jpg file after downloading from Flickr using Flickr Downloadr
for jpg in *.jpg; do exiftool -json=$jpg.json $jpg; done

@dixonge
dixonge / Rename-files-all-subdirectories
Last active April 2, 2020 16:45
Rename files in all subdirectories. . If the file name is the same, just use filename instead of 'pattern.ext' - if the file names are different, use a pattern like '*.md'
find . -iname pattern.ext -exec rename 's/oldname/newname/' '{}' \;
@dixonge
dixonge / Delete-line-only-if-blank-in-all-files-in-folder
Created April 2, 2020 16:41
Delete a line only if blank in all files in a folder
find ./ -type f -exec sed '1{/^$/d}' {} \;

@dixonge
dixonge / Delete-line-if-matches-pattern-all-files-in-folder
Created April 2, 2020 16:25
Delete a line if it matches a pattern in all files in a folder
sudo find ./ -type f -exec sed -i '/pattern-to-match/d' {} \; 

@dixonge
dixonge / Delete-lines-after-pattern-match-all-files-in-folder
Created April 2, 2020 16:24
Delete lines *after* a pattern match in all files in a folder
find ./ -type f -exec sed -e '/pattern/{n;N;N;N;N;d}' {} \; 

@dixonge
dixonge / Add-text-to-beginning-all-files-in-folder
Created April 2, 2020 16:23
Add a line of text to the beginning of all files in a folder
find ./ -type f -exec sed -i '1s/^/ \n/' {} \; 

@dixonge
dixonge / Make-Move.sh
Created April 2, 2020 16:21
Make a folder for each file, then move files to their matching folder. If you need to rename the file, add that at the end of the mv command line
#!/bin/bash
dir="/somedir/" for i in "$dir"*;
do if [ -f "$i" ];
then filename="${i%%.*}" if [ ! -d "$filename" ];
then sudo mkdir "$filename" fi sudo mv "$i" "$filename" fi
done