2009-04-30, 09:28
Tried a search but nothing came up. Looking for a batch script that will move all of a film's .avi/.mkv, .tbn, .nfo, etc. into a separate folder. I am sure you guys know what I mean.
Thanks!
Thanks!
Montellese Wrote:Well I think I'll end up writing my own program nonetheless which will move all the NFOs, fanarts, tbn, trailers etc to a new folder and rename the files.
This batch script only moves the files to new folders leaving me with all my additional files in the original place.
david81 Wrote:http://forum.xbmc.org/showpost.php?p=256...stcount=68
import os
import sys
badWords = ['bluray', 'hdtv', 'hddvd', '1080p', '720p', 'dvd5', 'dvd9', 'x264']
def fixFolder (folder):
for file in os.listdir(folder):
if file.endswith('.tbn'):
print ' Renaming tbn file', file
os.rename(os.path.join(folder, file), os.path.join(folder, 'movie.tbn'))
if file.endswith('.nfo'):
print ' Renaming nfo file', file
os.rename(os.path.join(folder, file), os.path.join(folder, 'movie.nfo'))
if file.endswith('-fanart.jpg'):
print ' Renaming fanart file', file
os.rename(os.path.join(folder, file), os.path.join(folder, 'fanart.jpg'))
if file.endswith('-big.png'):
print ' Deleting secondary thumb', file
os.remove(os.path.join(folder, file))
def sanitizeFileName (filename):
print 'file is', filename
goodName = filename[0:filename.rfind('.')]
goodName = goodName.replace('.', ' ')
goodName = goodName.replace(' ', '. ')
for badWord in badWords:
rPos = goodName.lower().rfind(badWord)
if rPos != -1:
goodName = goodName[0:rPos-1]
return goodName
def doFolder (whichDir):
for movie in filter(lambda x: x.endswith('.mkv') or x.endswith('.avi') or x.endswith('.iso'), os.listdir(whichDir)):
print 'Found file:', movie
goodName = sanitizeFileName(movie)
print ' Using sanitized name', goodName
print ' Creating folder...',
os.mkdir(os.path.join(whichDir, goodName))
print ' success.'
print ' Moving files...'
for movieFile in filter(lambda x: x.startswith(movie[0:movie.rfind('.')]) and not os.path.isdir(os.path.join(whichDir, x)), os.listdir(whichDir)):
print ' Moving', movieFile, '...',
os.rename(os.path.join(whichDir, movieFile), os.path.join(whichDir, goodName, movieFile))
print ' success.'
print ' Fixing names...'
fixFolder(os.path.join(whichDir, goodName))
doFolder(sys.argv[1])
Nmarconi Wrote:Below is the link to the .net program I threw together that will convert a folder full of flat movies like this:
All Movies\Movie Title.mkv (or avi, mp4, m4v, iso, mov, img)
All Movies\Movie Title.tbn
All Movies\Movie Title.nfo
All Movies\Movie Title-fanart.jpg
And converts to either of these options:
1)
All Movies\Movie Title\Movie Title.mkv (or whatever the original ext was)
All Movies\Movie Title\Movie Title.tbn
All Movies\Movie Title\Movie Title.nfo
All Movies\Movie Title\Movie Title-fanart.jpg
2)
All Movies\Movie Title\Movie Title.mkv
All Movies\Movie Title\movie.tbn
All Movies\Movie Title\movie.nfo
All Movies\Movie Title\fanart.jpg
THE PROGRAM WILL NOT WORK IF YOU HAVE YOUR MOVIES IN VOB FOLDERS!
THE PROGRAM WILL NOT MOVE TRAILERS!
THE PROGRAM WILL NOT WORK WITH STACKED FILES!
I HIGHLY RECOMMEND YOU SETUP A TEST FOLDER TO TRY OUT YOUR SPECIFIC SETUP.
http://www.mediafire.com/?indtoihihhy
Hope this helps! Also, seriously - please test it on a small folder to see if your specific setup presents any challenges i did not address. This is intended to be used in very strait forward simple setups.