Page 1 of 1
Script to move all files under the movie folder
Posted: December 23rd, 2013, 12:35 pm
by mrgoolie
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?
Re: Script to move all files under the movie folder
Posted: December 23rd, 2013, 1:36 pm
by sander
Yes, this is possible via a script.
pseudo-code:
Code: Select all
cd /nas/movies/The Kings of Summer/
mv */*.mkv .
The above is for Linux / *IX / OSX. I don't know about Windows.
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
Posted: December 24th, 2013, 7:05 pm
by mrgoolie
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?
sander wrote:Yes, this is possible via a script.
pseudo-code:
Code: Select all
cd /nas/movies/The Kings of Summer/
mv */*.mkv .
The above is for Linux / *IX / OSX. I don't know about Windows.
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
Posted: December 25th, 2013, 10:53 am
by sander
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
Posted: December 26th, 2013, 10:06 am
by mrgoolie
But the code
Code: Select all
cd /nas/movies/The Kings of Summer/
mv */*.mkv
isn't applicable for every movie

Re: Script to move all files under the movie folder
Posted: January 9th, 2014, 2:25 am
by Ectholian
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
Re: Script to move all files under the movie folder
Posted: January 26th, 2014, 5:37 am
by mrgoolie
Can you share your script?
