![]() |
|
|||||||
| Linux Apps and OS General - discussion not directly related to XBMC General Linux related chit-chat and discussions, (no support/help questions!) For support/help on non-XBMC related Linux stuff visit their OS support sites |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2009
Location: Canada
Posts: 122
![]() |
Does anyone know of a linux script that will move a bunch of movies from one directory to individual directories named after the movie file?
I have search and found nothing; only a few references in threads discussing the merit of putting movies all in one directory versus individual directories. |
|
|
|
|
#2 |
|
Grumpy Bastard Developer
Join Date: Nov 2003
Posts: 7,714
![]() |
Code:
for i in *; do \ test -d $i && continue; \ DIR=`echo $i | sed -e 's/\....//g'`; \ mkdir $DIR && mv $i $DIR/$i \ ; done
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting. Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. For troubleshooting and bug reporting please make sure you read this first. |
|
|
|
|
#3 |
|
Fan
Join Date: Jan 2008
Location: Edmonton, Canada
Posts: 444
![]() |
I made this (python) to do mine: (save to whatever.py and run python whatever.py /your/movie/dir/)
Code:
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])
Last edited by midgetspy; 2009-04-29 at 20:49. |
|
|
|
|
#4 |
|
Junior Member
Join Date: Jan 2009
Posts: 4
![]() |
I ended up using this app and instructions:
http://www.monkeyjob.com/FoldMonk/FA...-Move-File.htm It's trialware, but you only need to use it for all of 5 minutes to get the job done. Worked perfectly for me. Edit: Sorry, breezed right pass the linux script part. But it's a good tip for Windows users. Last edited by Mike48236; 2009-04-29 at 22:43. |
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2009
Location: Canada
Posts: 122
![]() |
Thanks everyone.!!!
Now I know I have made the right decision to jump from mythtv to xbmc, everyone is so responsive and helpful. Thanks again. Mike48236: that will work also, all my linux stuff is accessible from windows and that is how I manipulate most of it anyway. |
|
|
|
|
#6 |
|
Member
Join Date: Nov 2008
Posts: 46
![]() |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|