Skip to content

Instantly share code, notes, and snippets.

@dilawar
Last active November 4, 2015 13:01
Show Gist options
  • Save dilawar/12ae1b5c4baa94098013 to your computer and use it in GitHub Desktop.
Save dilawar/12ae1b5c4baa94098013 to your computer and use it in GitHub Desktop.
#!/bin/bash
SEPARATOR='_'
find . -maxdepth 1 -type f -name "*" -print0 | while read -d $'\0' file
do
IFS=$SEPARATOR read -a _file <<< "$file"
STUDENTDIR="${_file[0]}"
STUDENTDIR="${STUDENTDIR// /_}"
mkdir -p $STUDENTDIR
echo "Moving $file to $STUDENTDIR"
mv "$file" $STUDENTDIR
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment