Created
March 23, 2012 04:14
-
-
Save rothgar/2166713 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: filestodirs 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 | |
IFS=$'\n' | |
for file in `ls -1` | |
do | |
dirname=`echo "$file" | sed 's/\s([0-9]\+).*//' | |
filename=`echo "$file" | sed 's/\s([0-9]\+)//' | |
mkdir "$dirname" | |
mv "$file" "$dirname"/"$filename" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment