Created
March 27, 2022 04:13
-
-
Save RavinduSachintha/029fdc9bf5c97dfa699e4c3214598427 to your computer and use it in GitHub Desktop.
This shell script will create folders for files inside the current folder and move those files to their respective folders. Shell scripts are excluded. I usually use this for sorting movies and other videos in my machine.
This file contains 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 | |
process() { | |
folderName="$(basename "$1" | sed 's/\(.*\)\..*/\1/' | sed 's/ /_/g')" | |
mkdir -p $folderName | |
mv "$(basename "$1")" $folderName | |
} | |
export -f process | |
find . -maxdepth 1 -type f -not -name "*.sh" -exec bash -c 'process "$0"' {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment