Shell Scripts
Table of Contents
- [Batch Replace filename char.](#replace-filename-char)
- [Batch rename filename, uppercase to lower](#file-rename-uppercase-lower)
- [Batch file rename](#file-rename)
- [File size](#file-size)
- [Fuzzy cd](#fuzzy-cd)
- [Screenshot to clipboard](#screenshot-to-clipboard)
- [Shuffle images](#shuffle-images)
- [v1](#fuzzy-edit1)
- [v2](#fuzzy-edit2)
One-Liners
Replace filename char.
find . -name '* *' | while IFS= read -r f; do mv "$f" "$(echo "$f" | tr ' ' '_')"; done
This replaces every 'space' with an underscore
Convert uppercase filenames to loweer
for file in *; do mv "$file" "$(echo "$file" | tr '[:upper:]' '[:lower:]')"; done
Batch file rename
find . -type f -name 'index.md' -execdir mv '{}' i.md \;
File size
du -sk * | sort -nr | awk '{print $1/1024 " MB\t" $2}'
Fuzzy cd
cd $(find /var/www/werc/sites -type d \( -name .git -prune \) -o \( -type d -print \) | fzf) && clear
Screeenshot to clipboard
import png:- | xclip -selection c -t image/png
Shuffle images
find . -type f | shuf | nsxiv -ai