Skip to content

Instantly share code, notes, and snippets.

@sudodoki
Created September 7, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudodoki/37d9e49fca592ce20a4d648653da60d8 to your computer and use it in GitHub Desktop.
Save sudodoki/37d9e49fca592ce20a4d648653da60d8 to your computer and use it in GitHub Desktop.
split filename and move `abcdefgh.txt` -> `ab/cd/efgh.txt`.
#!/usr/bin/env bash
# find input -type f -maxdepth 1 | parallel --load 100% ./splitter.sh input {}
input_dir=$1
f=$2
if [[ -f $f ]]
then
filename=$(basename $f)
enclosing="${filename:0:1}/${filename:1:1}/"
mkdir -p "$input_dir/$enclosing"
mv $f "$input_dir/$enclosing$filename"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment