Skip to content

Instantly share code, notes, and snippets.

@dixonge
Created April 2, 2020 16:21
Show Gist options
  • Save dixonge/629cfd6b83363db9c88359d43c8f4882 to your computer and use it in GitHub Desktop.
Save dixonge/629cfd6b83363db9c88359d43c8f4882 to your computer and use it in GitHub Desktop.
Make a folder for each file, then move files to their matching folder. If you need to rename the file, add that at the end of the mv command line
#!/bin/bash
dir="/somedir/" for i in "$dir"*;
do if [ -f "$i" ];
then filename="${i%%.*}" if [ ! -d "$filename" ];
then sudo mkdir "$filename" fi sudo mv "$i" "$filename" fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment