Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Command to move all mkv files up a folder

Featured Replies

Quote

mv: cannot stat 'AUDIO_TS': No such file or directory

mv: cannot stat 'VIDEO_TS': No such file or directory

The mv will give an error if AUDIO_TS or VIDEO_TS do not exist.  I left the error in there so you could see if either directory wasn't present.  I can suppress the error if you want.

 

Quote

rev: stdin: Invalid or incomplete multibyte or wide character

mv: cannot move 'VIDEO_TS' to '/mnt/user/unraid/dvdbackup/VIDEO_TS': Directory not empty

I believe the reason the mv failed may be because of the rev error.

I modified the script to use sed instead of rev.  It may fix the error.

 

  • Author

I just run a search for VIDEO_TS and AUDIO_TS and DVD in the subfolders, they are all gone, so that's worked!

To double check, how do I find which folder does NOT contain

*.mkv
or
movie.xml

That will basically tell me if anything was wrong in the first place with a movie folder in the conversion or tagging process I run previously.
I think this would complete first pass, and I could add the directory to emby

Do you want the script to move "movie.xml" to the parent directory like the mkv file?

 

I could modify the script so that at the time of processing it checks if an mkv file exists, if not print a message.

Or I could make a separate script to check if the files exist.

  • Author
Do you want the script to move "movie.xml" to the parent directory like the mkv file?
 
I could modify the script so that at the time of processing it checks if an mkv file exists, if not print a message.
Or I could make a separate script to check if the files exist.
I did many random checks they all seem to be there, I already run the other script, so a separate script that just checks that the two files are there and gives an error message when they are not, like the VIDEO_TS error messages, would be fantastic! Thank you so much for your help on this!

Sent from my SM-A520F using Tapatalk

Check for movie.xml and mkv files in each movie folder.

check_movies.sh

#!/bin/bash

movies="/mnt/user/test/movies"

process()
{
    local movieDir=$1
    
    local mkv="$(find "$movieDir" -iname '*.mkv')"
    local xml="$(find "$movieDir" -iname 'movie.xml')"

    if [ -z "$mkv" ] || [ -z "$xml" ]
    then
        printf "$movieDir\n"
        [ -z "$mkv" ] && printf "\tmkv: file not found\n"
        [ -z "$xml" ] && printf "\tmovie.xml: file not found\n"
    fi
}

ls -1d "$movies"/*/ | sed 's/\/*$//' |\
while read movie
do
    if [ -d "$movie/DVD1" ]
    then
        ls -1d "$movie"/DVD*/ | sed 's/\/*$//' |\
        while read dvd
        do
            process "$dvd"
        done
    else
        process "$movie"
    fi
done

 

Edited by JoeUnraidUser

  • Author
Check for movie.xml and mkv files in each movie folder.
check_movies.sh
#!/bin/bashmovies="/mnt/user/test/movies"process(){   local movieDir=$1      mkv="$(find "$movieDir" -iname '*.mkv' -print -quit)"   xml="$(find "$movieDir" -iname 'movie.xml' -print -quit)"   if [ -z "$mkv" ] || [ -z "$xml" ]   then       printf "$movieDir\n"   fi      if [ -z "$mkv" ]   then       printf "\tmkv: file not found\n"   fi   if [ -z "$xml" ]   then       printf "\tmovie.xml: file not found\n"   fi}ls -1d "$movies"/*/ | sed 's/\/*$//' |\while read moviedo   if [ -d "$movie/DVD1" ]   then       ls -1d "$movie"/DVD*/ | sed 's/\/*$//' |\       while read dvd       do           process "$dvd"       done   else       process "$movie"   fidone

 

Awesome will test tonight

Sent from my SM-A520F using Tapatalk

  • Author

Perfect. It found 43 folder with no MKV file, probably because the mkv creator failed to convert the video_TS folder when I automated the mkv file generation.

Now I know what I need to fix, you have been fantastic, thanks Joe, this was a great help.

  • Author

makemkv fails on those folder, but handbrake is converting most of them fine, so off they go! It's not a "non-transcoding" method like makemkv, but the results are pretty good anyway

  • 2 months later...
  • Author

Merry Xmas Joe, if I want to find out which movie folder within a directory does not have a .nfo file, do I just replace *.mkv with *.nfo in the script above? I don't have any dvd folders anymore as I have converted them all to mkvs.

On 12/25/2019 at 1:44 PM, gnollo said:

Merry Xmas Joe, if I want to find out which movie folder within a directory does not have a .nfo file, do I just replace *.mkv with *.nfo in the script above? I don't have any dvd folders anymore as I have converted them all to mkvs.

Yes, it should work.

  • 3 weeks later...
  • Author

It worked indeed! Thank you for that Joe. Now I need to identify which folder in my /mnt/user/test/movies contains subfolders. Need to get rid of them as emby does not deal well with them.

On 1/17/2020 at 1:57 AM, gnollo said:

It worked indeed! Thank you for that Joe. Now I need to identify which folder in my /mnt/user/test/movies contains subfolders. Need to get rid of them as emby does not deal well with them.

 

The following script will show the subfolders for each movie.

 

 

To remove the subfolders; uncomment the following line:

#rm -rf "$dir"

to

rm -rf "$dir"

 

movies_subdirs.sh

#!/bin/bash

movies="/mnt/user/test/movies"

process()
{
    local movieDir=$1

    readarray -t dirs < <(find "$movieDir" -mindepth 1 -maxdepth 1 -type d -print 2>/dev/null)

    if [ ${#dirs[@]} != 0 ]
    then
        printf "$movieDir\n"
        
        for dir in "${dirs[@]}"
        do
            printf "$dir\n"    

            #rm -rf "$dir"
                
        done
    fi
}

ls -1d "$movies"/*/ | sed 's/\/*$//' |\
while read movie
do
    if [ -d "$movie/DVD1" ]
    then
        ls -1d "$movie"/DVD*/ | sed 's/\/*$//' |\
        while read dvd
        do
            process "$dvd"
        done
    else
        process "$movie"
    fi
done

 

  • Author

Thank you again, works like a charm!

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.