Created
November 15, 2017 22:25
-
-
Save AndriMar/116b3b1afb21130d615dbf8427adc504 to your computer and use it in GitHub Desktop.
Script to move file to folder with same name
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 | |
echo "Process folder $1" | |
for file in $1 | |
do | |
if [[ -f $file ]]; then | |
FILEPATH=`echo $file | sed 's/ /./g'` | |
FOLDER=${FILEPATH%.*} | |
echo "Create folder $FOLDER" | |
mkdir $FOLDER | |
echo "$file - > $FOLDER" | |
mv "$file" "$FOLDER" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Remember to
chmod +x move_movie.sh
How to run:
./movemovie.sh "/media2/XBMC/Movies/*"
If you want to run without creating and moving file comment out line 9 and 11