Created
February 17, 2022 00:10
-
-
Save androiddevnotes/578afd7319edfe34fa06e22a51ac45f7 to your computer and use it in GitHub Desktop.
Bash script to make directory from file name and move the file inside the directory. Run: bash script.sh
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 | |
for file in $(find . -name "*.md" -type f) | |
do | |
echo "file: $file" | |
filenamewithextension=${file##*/} | |
echo "file name with extension: $filenamewithextension" | |
mkdir ${filenamewithextension%.*} | |
echo "file name without extension: ${filenamewithextension%.*}" | |
mv ${filenamewithextension} ${filenamewithextension%.*}/${filenamewithextension} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment