Skip to content

Instantly share code, notes, and snippets.

@AndriMar
Created November 15, 2017 22:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndriMar/116b3b1afb21130d615dbf8427adc504 to your computer and use it in GitHub Desktop.
Save AndriMar/116b3b1afb21130d615dbf8427adc504 to your computer and use it in GitHub Desktop.
Script to move file to folder with same name
#!/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
@AndriMar
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment