So I have ripping a lot of movies and shows for my media server, and I have a bunch of movies that are not found in IMDB, but I found a app that can meta tag for me, the problem is the videos need to already in a folder that is named the movie.
So I am not sure if there is a app out there that can do this, or if there is a batch script I can run to do this.
I essentially need it to look at the files that I have, create a folder for it, and then move the file to that folder.
Like A.avi to Folder A
B.avi to Folder B
etc
Script help
- captain_twinkie
- DBB Ace
- Posts: 222
- Joined: Sun Mar 07, 2004 3:35 pm
- Location: Orem, Utah
Re: Script help
I suppose you're talking about windows, huh?
for linux, cd to the directory that contains the avi's:
Or something of the like. I just whipped out the code, and copied the sed part, so you should test it and tweak before you just run it on all on your files. I'm not sure how it will handle files that have multiple periods in the filename (I think it will cut everything off after the first period- test it with an "echo $DIR" and the mkdir and mv commands commented out to see how it processes different characters, esp. spaces and periods.)
If you're in windows, a POSIX shell, like cygwin, will handle this script properly.
[EDIT]Tutorial on sed: http://www.grymoire.com/Unix/Sed.html
for linux, cd to the directory that contains the avi's:
Code: Select all
#!/bin/bash
ls | grep .avi | while read -r FILE
do
DIR="(echo "$FILE" | sed 's/\(.*\)\..*/\1/')"
mkdir $DIR
mv $FILE $DIR
done
If you're in windows, a POSIX shell, like cygwin, will handle this script properly.
[EDIT]Tutorial on sed: http://www.grymoire.com/Unix/Sed.html
Arch Linux x86-64, Openbox
"We'll just set a new course for that empty region over there, near that blackish, holeish thing. " Zapp Brannigan
"We'll just set a new course for that empty region over there, near that blackish, holeish thing. " Zapp Brannigan
Re: Script help
To make it robust to file names with arbitrary white space:
MinGW also provides a POSIX shell on Windows.
There's also this thing called "Windows Power Shell" that I know nothing about, but if it's worth anything, it will support regular expressions.
Code: Select all
#!/bin/sh
for FILE in *.avi
do
DIR="$(echo "$FILE" | sed 's/\(.*\)\..*/\1/')"
mkdir -p "$DIR"
mv "$FILE" "$DIR/"
done
There's also this thing called "Windows Power Shell" that I know nothing about, but if it's worth anything, it will support regular expressions.