Hi all,
I've found a release group that posts good movies but when they are automaticly extracted via sabnzbd it looks like:
\\nas\movies\The Kings of Summer\TKoS1318pBRDSHQBRNLS-NLU002\The Kings of Summer (2013) 1080p BluRay DTS HQ-BR NL Subs.mkv
I want it like:
\\nas\movies\The Kings of Summer\The Kings of Summer (2013) 1080p BluRay DTS HQ-BR NL Subs.mkv
So in fact I need to move the .mkv file a folder up.
Most of my other downloads are extracted the correct way.
The reason why I ask this is because my xbmc doesn't find folder/folder/movie.mkv but only folder/movie.mkv
Is this possible via a script?
Script to move all files under the movie folder
Re: Script to move all files under the movie folder
Yes, this is possible via a script.
pseudo-code:
The above is for Linux / *IX / OSX. I don't know about Windows.
EDIT: manual example:
pseudo-code:
Code: Select all
cd /nas/movies/The Kings of Summer/
mv */*.mkv .
EDIT: manual example:
Code: Select all
sander@flappie:~$ cd Movie1/
sander@flappie:~/Movie1$ ls -al
total 12
drwxr-xr-x 3 sander sander 4096 dec 23 19:37 .
drwxr-xr-x 65 sander sander 4096 dec 23 19:37 ..
drwxr-xr-x 2 sander sander 4096 dec 23 19:37 some-sub-dir
sander@flappie:~/Movie1$
sander@flappie:~/Movie1$
sander@flappie:~/Movie1$ mv */*.mkv .
sander@flappie:~/Movie1$
sander@flappie:~/Movie1$ ls -al
total 12
drwxr-xr-x 3 sander sander 4096 dec 23 19:38 .
drwxr-xr-x 65 sander sander 4096 dec 23 19:37 ..
-rw-r--r-- 1 sander sander 0 dec 23 19:37 some-movie.mkv
drwxr-xr-x 2 sander sander 4096 dec 23 19:38 some-sub-dir
sander@flappie:~/Movie1$
Re: Script to move all files under the movie folder
In fact i'm looking for a code that is usable for every movie I download.
for example:
\\nas\movies\test\test\test.mkv -> \\nas\movies\test\test.mkv
but also: \\nas\movies\test\test.mkv -> \\nas\movies\test\test.mkv (stays the same)
So maybe it is possible to build a check in the script?
for example:
\\nas\movies\test\test\test.mkv -> \\nas\movies\test\test.mkv
but also: \\nas\movies\test\test.mkv -> \\nas\movies\test\test.mkv (stays the same)
So maybe it is possible to build a check in the script?
sander wrote:Yes, this is possible via a script.
pseudo-code:
The above is for Linux / *IX / OSX. I don't know about Windows.Code: Select all
cd /nas/movies/The Kings of Summer/ mv */*.mkv .
EDIT: manual example:
Code: Select all
sander@flappie:~$ cd Movie1/ sander@flappie:~/Movie1$ ls -al total 12 drwxr-xr-x 3 sander sander 4096 dec 23 19:37 . drwxr-xr-x 65 sander sander 4096 dec 23 19:37 .. drwxr-xr-x 2 sander sander 4096 dec 23 19:37 some-sub-dir sander@flappie:~/Movie1$ sander@flappie:~/Movie1$ sander@flappie:~/Movie1$ mv */*.mkv . sander@flappie:~/Movie1$ sander@flappie:~/Movie1$ ls -al total 12 drwxr-xr-x 3 sander sander 4096 dec 23 19:38 . drwxr-xr-x 65 sander sander 4096 dec 23 19:37 .. -rw-r--r-- 1 sander sander 0 dec 23 19:37 some-movie.mkv drwxr-xr-x 2 sander sander 4096 dec 23 19:38 some-sub-dir sander@flappie:~/Movie1$
Re: Script to move all files under the movie folder
The pseudo-code I gave you does take care of that. You can try that for yourself.
Re: Script to move all files under the movie folder
But the code
isn't applicable for every movie 
Code: Select all
cd /nas/movies/The Kings of Summer/
mv */*.mkv

Re: Script to move all files under the movie folder
find "$1" -mindepth 2 -type f -exec mv "{}" "$1" \;
$1 is the full path to the directory where the movie is downloaded (the folder where you want your .mkv)
-mindepth 2 is needed so the command don't execute for the current dir, which would make an endless loop
-type f takes care of only files
and the exec just does a mv 'foundfile' 'moviedirectory'
Something like this should work.
Edit: this one should be a little more efficient, since it only uses one single mv call:
find "$1" -mindepth 2 -type f -exec mv -t "$1" "{}" +
My script i use does a couple things:
- move all files to the main directory
- delete all subdirectories (which should contain no files anymore)
- delete all non-movie files (*.jpg, url, html etc. etc.)
- append a ' - DVD', ' - Bluray' or a ' - ISO' to the name of the folder if it contains a dvd, bluray or iso
- clean xbmc library
- scan xbmc library
$1 is the full path to the directory where the movie is downloaded (the folder where you want your .mkv)
-mindepth 2 is needed so the command don't execute for the current dir, which would make an endless loop
-type f takes care of only files
and the exec just does a mv 'foundfile' 'moviedirectory'
Something like this should work.
Edit: this one should be a little more efficient, since it only uses one single mv call:
find "$1" -mindepth 2 -type f -exec mv -t "$1" "{}" +
My script i use does a couple things:
- move all files to the main directory
- delete all subdirectories (which should contain no files anymore)
- delete all non-movie files (*.jpg, url, html etc. etc.)
- append a ' - DVD', ' - Bluray' or a ' - ISO' to the name of the folder if it contains a dvd, bluray or iso
- clean xbmc library
- scan xbmc library
Re: Script to move all files under the movie folder
Can you share your script? 
