Skip to content

Instantly share code, notes, and snippets.

@ArneAnka
ArneAnka / gist:bf636079faa9df86f7511b38982424ed
Created May 11, 2017 11:42
Search images of a specific dimension
# This scripts helps you when seraching images of a speceifc dimension. Lets
# say you want to remove thumbnails or something, then this is good!
# Notice the `echo`, remove that and run the script. That will REMOVE you files.
# Change `rm` to `cp` to copy the files if you want to review them before deletion.
```
#!/bin/bash
targetDir="$HOME/Pictures"
@ArneAnka
ArneAnka / gist:f245043a1fd2a29c68cb4f71b78203c7
Created April 10, 2017 20:01
Extract rar files recursively and remove the rar files afterwards
# Assuming extglob option of bash is set, which is the default, otherwise set with shopt -s extglob
# http://askubuntu.com/a/903235/562529
`find . -name '*.rar' -exec unrar e {} \; -exec rm {} \; && rm *.r+([[:digit:]])`
# Maybe better option?
find . -name '*.rar' -exec unrar e {} \; -exec rm {} \; && rm *.r*
@ArneAnka
ArneAnka / gist:051571f0306c52a9aeccc4c6eee28448
Last active June 30, 2019 11:44
Find images, and copy or move them
# Two scripts that do the same thing a little different, notice `mv` and `cp`. Your choice
# What will happen is that find will recursivly serach the current folder for images, read when
# the file was created, and move/copy it to a corresponding folder.
# This is from https://apple.stackexchange.com/questions/280252/recursively-search-for-images-and-move-them-to-a-date-folder
# http://unix.stackexchange.com/a/83838
find -E . -regex '.*\.(jpg|JPG|png|PNG|jpeg|JPEG|bmp|BMP)' | while read file; do
ts=$(stat -f '%Sm' -t '%Y-%m-%d' "$file")
folder="/Users/username/Documents/Backup_images/$ts"