Created
April 2, 2020 16:21
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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