Skip to content

Instantly share code, notes, and snippets.

@awaxa
Created December 4, 2015 22:18
Show Gist options
  • Select an option

  • Save awaxa/d1afc1b09f6a5adcb0b3 to your computer and use it in GitHub Desktop.

Select an option

Save awaxa/d1afc1b09f6a5adcb0b3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
SOURCE='source'
TARGET='target'
for file in $(find $SOURCE -type f -name \*.txt) ; do
filename="$(basename $file)"
first="$(echo $filename | cut -c1)"
mkdir -p $TARGET/$first
mv -v $file $TARGET/$first/$filename
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment