Last active
May 22, 2023 00:26
-
-
Save AleixMT/2e1c3faba7556cad020fa3ce28876ae1 to your computer and use it in GitHub Desktop.
Put all the files with the same name without extension in the current working directory into a new folder which has the same name.
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
| shopt -s nullglob | |
| rev() | |
| { | |
| copy=$1 | |
| len=${#copy} | |
| for((i=$len-1;i>=0;i--)); do rev="$rev${copy:$i:1}"; done | |
| echo $rev | |
| } | |
| for filename in *; do | |
| if [ -d "${filename}" ]; then | |
| continue | |
| fi | |
| if [ "${filename}" == "putinfolders.sh" ] || [ "${filename}" == "desktop.ini" ]; then | |
| continue | |
| fi | |
| filename_noext="$(rev "$(rev "${filename}" | cut -d "." -f2-)")" | |
| mkdir -p "${filename_noext}" | |
| for this_movie_elem in "${filename_noext}".*; do | |
| mv "${this_movie_elem}" "${filename_noext}" | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment