-
-
Save aauren/2176543 to your computer and use it in GitHub Desktop.
Script for moving movie files
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
#!/bin/bash | |
# | |
# Usage: movie_move.sh directory_name | |
# | |
# Moves all files in the specified directory into | |
# subdirectories of the same name, minus the file | |
# extension. | |
if [ $# -ne 1 ]; then | |
echo "Usage: ./filestodirs directory_name" | |
exit 1 | |
fi | |
cd $1 | |
for file in $(ls); do | |
dest_dirname=$(echo "$file" | sed 's/\s([0-9]\+).*//') | |
dest_filename=$(echo "$file" | sed 's/\s([0-9]\+)//') | |
mkdir "${dest_dirname}" | |
mv "${file}" "${dest_dirname}/${dest_filename}" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment