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.

Feature request - New split level option

Featured Replies

I don't want to create different shares for every type of content I store on my unRAID server. Ideally I'd like one share with everything on it, but then I'm limited to one split level.

 

I also don't want to have to change my folder names to include some random non-numeric character if I don't want it's contents split.

 

I have two ideas for new options.

 

1) Have unRAID look for a .unraid-split-level file in each directory. This would be a hidden file on most operating systems, and the contents of the file would set the split level for that folder and sub-folders. It could be relative to the folder containing the .unraid-split-level file, or relative to the share root. This would allow multiple split levels on a single share. So your movies and your TV shows and your music could all have different split level options.

 

2) Have an option to split folders only (never split files). This could also be set for a specific folder only in the .unraid-split-level file above. So you can have whatever structure you like, with different types of content that are grouped at different levels, and your actual files will never be split. So your multi-part files for one movie will be on the same disk, but movies (if in a folder for each movie) could be on different disks. If you put your TV shows into one folder for each series, then each series will be on one disk. If you use season folders, then each season will be on one disk. If you store your iTunes music on unRAID, each album would not be split, etc.

 

Example (with a single share, unRAID):

 

unRAID/Documents/Resume.doc - disk 1

unRAID/Documents/Budget.xls - disk 1

unRAID/Documents/Invoices/0001.pdf - disk 2

unRAID/Documents/Invoices/0002.pdf - disk 2

unRAID/Movies/Batman/Batman (1).avi - disk 1

unRAID/Movies/Batman/Batman (2).avi - disk 1

unRAID/Movies/Hunger/Hunger.avi - disk 2

unRAID/Music/Miles Davis/Kind Of Blue/01...mp3 - disk 1

unRAID/Music/Miles Davis/Kind Of Blue/02...mp3 - disk 1

unRAID/Music/Miles Davis/Kind Of Blue/03...mp3 - disk 1

unRAID/Music/Miles Davis/Bitches Brew/01...mp3 - disk 2

unRAID/Music/Miles Davis/Bitches Brew/02...mp3 - disk 2

unRAID/Music/Miles Davis/Bitches Brew/03...mp3 - disk 2

unRAID/TV/Dexter/1x01...avi - disk 1

unRAID/TV/Dexter/1x02...avi - disk 1

unRAID/TV/Dexter/2x01...avi - disk 1

unRAID/TV/Sopranos/Season 1/01...avi - disk 2

unRAID/TV/Sopranos/Season 1/02...avi - disk 2

unRAID/TV/Sopranos/Season 2/01...avi - disk 1

unRAID/TV/Sopranos/Season 2/02...avi - disk 1

 

Maybe the option to split folders only could be applied in combination with the existing split level. Maybe a negative number could indicate that the split level applies to folders only. E.g. split level 0, everything on one disk. Split level 1, top level folders and files can be split. Split level -1, top level folders can be split but top level files will all be on one disk. Split level 3, files and folders can be split up to 3rd level deep. Split level -3, only folders can be split up to 3rd level deep.

 

Cheers.

 

You can sort of accomplish this yourself by placing a String value inside the split level instead of a number, such as "[]". I haven't used that feature so I'm not sure on specifics.

  • Author

You can sort of accomplish this yourself by placing a String value inside the split level instead of a number, such as "[]". I haven't used that feature so I'm not sure on specifics.

I mentioned that I don't want to have to butcher all my folder names with [] or some other random non-numeric string to disable splitting for all my folders :)

 

EDIT: It seems that the point of the split-level option is to keep related files together, e.g. tracks of an album, multi-part videos, etc. File systems already have folders for this purpose (grouping files). So why not just keep files in a single folder together? The only time I can think of when you would want files in a single folder split across disks is if you put all your movie files in one folder, but that seems a less common way that people organise videos. This change could be implemented backwards compatible, and people could use the existing behaviour if they want to do that.

 

What do you do with say a Movies share with some metadata (pic and maybe a xml file) in the main share? Do you then not split the directories for each individual movie and keep them all together?

 

Peter

  • Author

What do you do with say a Movies share with some metadata (pic and maybe a xml file) in the main share? Do you then not split the directories for each individual movie and keep them all together?

 

Peter

 

I don't understand your question. Do you have an example? The need to split level is to prevent stuttering when transitioning from one file to another during playback (e.g. of a movie, or album). If files are never automatically split, only folders, then this shouldn't be a problem?

 

Most people keep manageable numbers of files in a single folder (e.g. one movie per folder, one album per folder, one season or series of TV episodes per folder), so I think this method should work out of the box for most people.

 

If anyone does have an extremely large number of large files in one folder (e.g. all movie files or all mp3's in one folder) then the user could enable the traditional split level behaviour for that folder with the .unraid-split-level file. If per directory configuration via a .unraid-split-level file is not possible, then people would still have the choice between traditional split level behaviour and splitting folders only for each share.

 

Personally, I'd like to just split folders and always keep files in the same folder and have one share for all my data, and just use folders (without needing special characters in their name) to control splitting.

Say I have a picture in Movies so that it appears on my cool graphical front-end. Then, each movie is in a subdirectory with the associated files. How will this case be handled?

 

All the directory examples you listed will work with a level 1 or level 2 setting.

 

My TV share wouldn't even come close to working just by keeping files in each folder together.

 

\TV

\TV\image.jpg   -> don't want this to not allow the TV to split

\TV\Series#1

\TV\Series#1\image.jpg  -> might want this one to keep the Series#1 together but might only want each season together

\TV\Series#1\Season#1

\TV\Series#1\Season#1\episodes.mpg   -> want this one to keep the season together

\TV\Series#1\Season#1\metatdata  

\TV\Series#1\Season#1\metatdata\metafiles.xml    -> don't want this metadata to end up on a different disk

 

So, how is the above handled so my TV share can split but the metadata doesn't end up on a different disk?

 

Peter

 

  • Author

Say I have a picture in Movies so that it appears on my cool graphical front-end. Then, each movie is in a subdirectory with the associated files. How will this case be handled?

 

All the directory examples you listed will work with a level 1 or level 2 setting.

 

My TV share wouldn't even come close to working just by keeping files in each folder together.

 

\TV

\TV\image.jpg   -> don't want this to not allow the TV to split

\TV\Series#1

\TV\Series#1\image.jpg  -> might want this one to keep the Series#1 together but might only want each season together

\TV\Series#1\Season#1

\TV\Series#1\Season#1\episodes.mpg   -> want this one to keep the season together

\TV\Series#1\Season#1\metatdata  

\TV\Series#1\Season#1\metatdata\metafiles.xml    -> don't want this metadata to end up on a different disk

 

So, how is the above handled so my TV share can split but the metadata doesn't end up on a different disk?

 

Peter

 

 

You've misunderstood my request. I want folders to split, but not files. Given your structure, any files in any folder could be on any particular disk, but they would be on the same disk.

 

Files in \TV (only image.jpg in this example) could be on disk 1, and files in \TV\Series#1 (again only image.jpg here) could be on disk 2 even though the folder \TV\Series#1\Season#1 and all its files could be on disk 3 and \TV\Series#1\Season#2 on disk 4.

 

Having a file in the top level TV directory won't stop folder in TV from being split across disks, but it will keep all files in TV on the same disk. If you use season folders for your TV shows, each season will be on one disk. If you put all episode files in a series folder, then each series will be on one disk.

 

If you wanted to use this method as the default but apply a hard coded split level to keep your metadata which is in a sub-folder on the same disk as the episode.mpg files, then you would use the .unraid-split-level file in the common ancestor of all folders you want it to affect. So if everything in TV has the same structure, you could put it in TV. If you wanted to apply the split level only to a particular series, you'd put it in there.

 

My beef with split level is that it is currently either a hard coded nesting level or a hard coded string that I need to add to my folder names which is applied to the entire share. Different types of content (movies, TV shows, music) need different split levels. But I don't want different shares for different types of content. And I also want to store non-media content on the array (documents, invoices, source code files, etc). One share would work best for me, and I don't care about the actual split level, I just want files that are sensitive to time delays to be grouped together. For me, that's any files that are grouped in a folder. In some cases (such as your metadata example, or source code that has many nested folders) I might want to prevent splitting of folders as well, which is where the .unraid-split-level file would come in that would allow me to configure a split level for a folder (without renaming the folder) instead of a whole share.

 

OK, I can see what you are asking but I think I'll just stick to having a TV share with a split level of 1 keeping each complete series together.

 

I will also say that most users can hardly understand the split level as a number so almost no-one will figure out how to use this combination.

 

Peter

 

extra files and the like spread all over the place is not something that I want to see added.

 

I better approach/refinement to split level is a more graphical selection of what you want done.

 

An as far as one large data share... I have never been a fan of this approach and prefer to have my data split up into different shares.

 

If you need one large share you should be able to use the samba-extra.conf file to do it.  You will have to set it up yourself, but it is possible.

  • Author

OK, I can see what you are asking but I think I'll just stick to having a TV share with a split level of 1 keeping each complete series together.

 

I will also say that most users can hardly understand the split level as a number so almost no-one will figure out how to use this combination.

 

Peter

 

It's actually quite simple at the core. I think for most people simply not caring about "split level" at all and simply saying "don't split files" or "split folders only" would solve the problem of stuttering playback while still allowing content to be split across disks.

 

  • Author

extra files and the like spread all over the place is not something that I want to see added.

 

I better approach/refinement to split level is a more graphical selection of what you want done.

 

An as far as one large data share... I have never been a fan of this approach and prefer to have my data split up into different shares.

 

If you need one large share you should be able to use the samba-extra.conf file to do it.  You will have to set it up yourself, but it is possible.

 

What extra files? There is no need for extra files all over the place. It should be enough in most cases to simply say "don't split files, only split folders". The suggested .unraid-split-level file is a separate issue that would allow different settings for different folders on a single share. I much prefer this to mangling all my folder names with "[]" (or some other) characters.

 

extra files and the like spread all over the place is not something that I want to see added.

 

I better approach/refinement to split level is a more graphical selection of what you want done.

 

An as far as one large data share... I have never been a fan of this approach and prefer to have my data split up into different shares.

 

If you need one large share you should be able to use the samba-extra.conf file to do it.  You will have to set it up yourself, but it is possible.

I'm not sure what you are intending.

 

What extra files? There is no need for extra files all over the place. It should be enough in most cases to simply say "don't split files, only split folders". The suggested .unraid-split-level file is a separate issue that would allow different settings for different folders on a single share. I much prefer this to mangling all my folder names with "[]" (or some other) characters.

 

Files are NEVER split across disks.  It is a limitation of unRAID that any given file most reside in a single file-system on a single data disk.

 

A folder may be duplicated across multiple disks.

 

So, if you have a set of follders

Movies/Action

and in it folders for

  Die Hard 1

  Die Hard 2

  Lethal Weapon 1

  Lethal Weapon 2

  True Lies

 

And in each folder are the .VOB files for each movie...

 

Now, you say files should not be split... That is a given.  They can't

By if the split level is a high enough number (3 in this example) Any of the movie-title directories could be split across disks.

 

You could have a

  Disk1/Movies/Action/True Lies/chapter1.VOB

  Disk2/Movies/Action/True Lies/chapter2.VOB

 

The directory was split.  Files were not.  To prevent them from being split you would need a split level of 2.    Then "Movies/Action" would be the lowest level directory split across disks.  All the directories in the next level would remain on a single disk. (True Lies would remain on a single disk)

  • Author

Files are NEVER split across disks.  It is a limitation of unRAID that any given file most reside in a single file-system on a single data disk.

 

A folder may be duplicated across multiple disks.

 

So, if you have a set of follders

Movies/Action

and in it folders for

   Die Hard 1

   Die Hard 2

   Lethal Weapon 1

   Lethal Weapon 2

   True Lies

 

And in each folder are the .VOB files for each movie...

 

Now, you say files should not be split... That is a given.  They can't

By if the split level is a high enough number (3 in this example) Any of the movie-title directories could be split across disks.

 

You could have a

   Disk1/Movies/Action/True Lies/chapter1.VOB

   Disk2/Movies/Action/True Lies/chapter2.VOB

 

The directory was split.  Files were not.  To prevent them from being split you would need a split level of 2.    Then "Movies/Action" would be the lowest level directory split across disks.   All the directories in the next level would remain on a single disk. (True Lies would remain on a single disk)

 

I know how split level currently works. I'm not talking about splitting single files. I'm talking about not separating (splitting) files that are grouped together in a single folder across multiple disks. I don't want to deal with the current "split level" feature because it's confusing and the folder depth not a good mechanism for determining which files and folders should go on which disk because it relies on a fixed hierarchy that is specific to one type of content which therefore requires different shares for each type of content.

 

I'd like a simpler option which says "keep files in the same folder on the same disk, but allow folders in the same folder to go on different disks".

 

It's just another option, like looking for "[]" in the path.

 

The rest of the feature request (the .unraid-split-level file) is to allow any combination of split level options (a number, a non-numeric string, or my new request) to be applied at the folder level instead of the share level, which would benefit everyone who doesn't want a different share for every type of content, regardless of which split level option they prefer.

 

I'd like a simpler option which says "keep files in the same folder on the same disk, but allow folders in the same folder to go on different disks".

That description is more clear of what you would like.  I think that would work for some like yourself who have multiple files per movie.  It would certainly work for music where there are multiple tracks per album.  I think it deserves to be considered for the development roadmap.

 

That rule would not work for my movies since they are all single .ISO files.  (although they have an affiliated .nfo and .jpg file with the same base name.)  For me, an allocation method to not split files with the same base-name and different extensions would work.

 

Fortunately, I store my movies in alpha-ranges on my physical disks, and do not write them using user-shares, so I know my files are not split for a given movie.  I also have a script I wrote that will re-balance the files across the disks so they all have the same relative percentage of free space.  (It moves them as needed from one physical disk to another)

  • Author

That description is more clear of what you would like.  I think that would work for some like yourself who have multiple files per movie.   It would certainly work for music where there are multiple tracks per album.   I think it deserves to be considered for the development roadmap.

 

That rule would not work for my movies since they are all single .ISO files.  (although they have an affiliated .nfo and .jpg file with the same base name.)   For me, an allocation method to not split files with the same base-name and different extensions would work.

 

Fortunately, I store my movies in alpha-ranges on my physical disks, and do not write them using user-shares, so I know my files are not split for a given movie.  I also have a script I wrote that will re-balance the files across the disks so they all have the same relative percentage of free space.  (It moves them as needed from one physical disk to another)

 

In your case (and probably others, e.g. when people have MovieName-fanart.jpg, MovieName.en.srt, MovieName-trailer.mov), perhaps a "stacking" feature (similar to XBMC) would work. In XBMC multiple stacking regular expressions can be defined and matching files will be treated as one by XBMC. For our purposes, they would be treated as one entity and not separated across disks. Such a regular expression could be:

 

(.+)(\.-fanart.jpg|-trailer\.mov|\.jpg|\.nfo|\.tbn)

 

This is a bit more complex as it requires knowledge of regular expressions by the user, but the unRAID interface could easily give common examples that can be used to cover most cases and modified by the user.

 

UPDATE: How does one get a feature into consideration for the development roadmap? Ideally the split level system should be not one way or the other, but more flexible to allow for different use cases (not only mine or yours or the existing one).

 

You basically do what you did (post up the idea) and hope it gets picked-up. I could see some people finding the ability to set the split to just keep files in a folder together very simple to use. It would work for my Movies share but it will not do what I want for my TV share.

 

Peter

Split level is the biggest (unavoidable) kludge in unRAID.

 

I see so many new users botch it and then copy a mound of data to their brand new array only to have it spread hither and yon, and then spend 4x as much time trying to straighten out the mess.

 

Best advice I can give - DO NOT USE USER SHARES / SPLIT LEVELS to do initial data load.  Copy your data to disk shares, then learn and experiment with split levels, and only then start writing to user shares if you must.

 

I am like Joe L. and always copy my data directly to the disks that I want them copied to.  But I tend to fill up a disk at a time.  And then create PAR2 blocks on that disk.  And then start writing to the next one.

 

I personally don't like the idea of having configuration data spread out in every directory.  Support would be very difficult, as would figuring out why something didn't work as expected.  I always throught split level of "VIDEO_TS" might be popular to keep DVD files together, but obviously that hasn't been the solution.  Not sure there is a perfect solution to this problem.

  • Author

Split level is the biggest (unavoidable) kludge in unRAID.

 

I see so many new users botch it and then copy a mound of data to their brand new array only to have it spread hither and yon, and then spend 4x as much time trying to straighten out the mess.

 

Best advice I can give - DO NOT USE USER SHARES / SPLIT LEVELS to do initial data load.  Copy your data to disk shares, then learn and experiment with split levels, and only then start writing to user shares if you must.

 

I am like Joe L. and always copy my data directly to the disks that I want them copied to.  But I tend to fill up a disk at a time.  And then create PAR2 blocks on that disk.  And then start writing to the next one.

 

I personally don't like the idea of having configuration data spread out in every directory.  Support would be very difficult, as would figuring out why something didn't work as expected.  I always throught split level of "VIDEO_TS" might be popular to keep DVD files together, but obviously that hasn't been the solution.  Not sure there is a perfect solution to this problem.

 

Configuration doesn't have to be spread out. It's just an option, if you want to take advantage of it. Like .htaccess files on a web server. The same thing could be accomplished with a central configuration area, but that would require an administrative interface built around selecting folders and applying settings to those folders. A .htaccess style file should be simple and easy to use and implement. There are also advantages to having distributed split level configuration. Keeps the instructions with your data, so that if your unRAID config is updated or lost or whatever, your files still know that they should be kept on the same disk. It's the same old debate with movie and TV show metadata. Keep it with the files (MovieName.tbn, MovieName-fanart.jpg) or keep it all together in a separate metadata area.

 

I'd like a simpler option which says "keep files in the same folder on the same disk, but allow folders in the same folder to go on different disks".

That description is more clear of what you would like.  I think that would work for some like yourself who have multiple files per movie.   It would certainly work for music where there are multiple tracks per album.   I think it deserves to be considered for the development roadmap.

 

That rule would not work for my movies since they are all single .ISO files.  (although they have an affiliated .nfo and .jpg file with the same base name.)   For me, an allocation method to not split files with the same base-name and different extensions would work.

 

Fortunately, I store my movies in alpha-ranges on my physical disks, and do not write them using user-shares, so I know my files are not split for a given movie.  I also have a script I wrote that will re-balance the files across the disks so they all have the same relative percentage of free space.  (It moves them as needed from one physical disk to another)

 

Hii Joe

 

i would love to have a script like this. (that will re-balance the files across the disks)

have you ever posted it? could i see it? and how does it work?

 

thank you

I also have a script I wrote that will re-balance the files across the disks so they all have the same relative percentage of free space.  (It moves them as needed from one physical disk to another)

 

Hii Joe

 

i would love to have a script like this. (that will re-balance the files across the disks)

have you ever posted it? could i see it? and how does it work?

 

thank you

 

Why?  I know that a disk that is too full it can interfere with running certain recovery tools.  But why is it valuable to keep the levels balanced.  Seems like a lot of unnecessary disk I/O.

I also have a script I wrote that will re-balance the files across the disks so they all have the same relative percentage of free space.  (It moves them as needed from one physical disk to another)

 

Hii Joe

 

i would love to have a script like this. (that will re-balance the files across the disks)

have you ever posted it? could i see it? and how does it work?

 

thank you

 

Why?  I know that a disk that is too full it can interfere with running certain recovery tools.  But why is it valuable to keep the levels balanced.  Seems like a lot of unnecessary disk I/O.

It is a lot of I/O, but there is one huge advantage to my older media players.  They croak when presented with a listing of a single "Movies" share with over 1000 movies.  (and it is very difficult to get to a movie towards the end of the listing as it only shows 16 titles at a time.)

 

By splitting up the single "Movies" share into alpha ranges I can select a subset of movies to browse through.  In addition, it minimizes the set of disks that are potentially spun up when that range is being accessed.

 

I also have a combined "Movies" share that shows all the movies for use by my media players that run XBMC.  I create hard links on the disks themselves so the same ISO image shows up under both listings.  Again, the script creates the links, so I just need to run the script that creates all the "mv" commands, and then run a second script that creates all the links to the alpha-range shares.

 

Yes, I think I did post the script at one time.  But do not remember which post and I know I made a lot of posts since then.

Here is one reference:

http://lime-technology.com/forum/index.php?topic=4959.msg45768#msg45768

 

In any case, here is the script.

m='echo rsync -i -dPpEAXogtvv --numeric-ids --inplace --remove-source-files'

#

for d in /mnt/disk[0-9]*

do

  cd "$d"

  rm Movies\ A-D/*.[ii][ss][Oo] 2>/dev/null

  rm Movies\ E-J/*.[ii][ss][Oo] 2>/dev/null

  rm Movies\ K-O/*.[ii][ss][Oo] 2>/dev/null

  rm Movies\ P-S/*.[ii][ss][Oo] 2>/dev/null

  rm Movies\ T-Z/*.[ii][ss][Oo] 2>/dev/null

  rm Movies\ A-D/*.[Aa][Vv][ii] 2>/dev/null

  rm Movies\ E-J/*.[Aa][Vv][ii] 2>/dev/null

  rm Movies\ K-O/*.[Aa][Vv][ii] 2>/dev/null

  rm Movies\ P-S/*.[Aa][Vv][ii] 2>/dev/null

  rm Movies\ T-Z/*.[Aa][Vv][ii] 2>/dev/null

  rm Movies\ A-D/*.[Mm][Pp][Gg] 2>/dev/null

  rm Movies\ E-J/*.[Mm][Pp][Gg] 2>/dev/null

  rm Movies\ F-J/*.[Mm][Pp][Gg] 2>/dev/null

  rm Movies\ K-O/*.[Mm][Pp][Gg] 2>/dev/null

  rm Movies\ P-S/*.[Mm][Pp][Gg] 2>/dev/null

  rm Movies\ T-Z/*.[Mm][Pp][Gg] 2>/dev/null

  rm Movies\ A-D/*.{tbn,nfo,jpg} 2>/dev/null

  rm Movies\ E-J/*.{tbn,nfo,jpg} 2>/dev/null

  rm Movies\ F-J/*.{tbn,nfo,jpg} 2>/dev/null

  rm Movies\ K-O/*.{tbn,nfo,jpg} 2>/dev/null

  rm Movies\ P-S/*.{tbn,nfo,jpg} 2>/dev/null

  rm Movies\ T-Z/*.{tbn,nfo,jpg} 2>/dev/null

  rmdir Movies\ A-D 2>/dev/null

  rmdir Movies\ E-J 2>/dev/null

  rmdir Movies\ K-O 2>/dev/null

  rmdir Movies\ P-S 2>/dev/null

  rmdir Movies\ T-Z 2>/dev/null

done

 

# add commas to a numeric argument for better readability

# yes, it is a "sed" script with a loop and a "goto"

# Found on the web, I did not write it myself. Original author unknown.

format_number() {

  echo " $1 " | sed -r ':L;s=\b([0-9]+)([0-9]{3})\b=\1,\2=g;t L'

}

 

# Step 1.  Get the total disk space available

totalfree=0

totalspace=0

totalother=0

totalavailable=0

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

do

# If there is a "Movies" share, get the total space used by all the ISO MPG, and AVI, nfo, and tbn image files on it.

if [ -d /mnt/disk$i/Movies ]

then

  disk_movies[$i]=`ls -s -1 /mnt/disk$i/Movies/*.[iiAaMmntj][ssVvPpfb][OoIiGgon] | awk '{total += $1} END {print total}'`

  total_movies=$(($totalspace + ${disk_movies[$i]}))

else

  # No movies share, store a zero space available.

  disk_movies[$i]=0

fi

 

# Now, get the total available space on the disk.

if [ -d /mnt/disk$i ]

then

  disksize=`df /mnt/disk$i 2>/dev/null | grep "/dev/md" | awk '{print $2'}`

  if [ "$disksize" != "" ]

  then

      disk_size[$i]=$disksize

      totalspace=$(($totalspace + ${disk_size[$i]}))

  fi

else

  disk_size[$i]=0

fi

 

# Now, get the total free space for the disk.  Add the free-space to that used by the movie ISO and AVI images.

if [ -d /mnt/disk$i ]

then

  freespace=`df /mnt/disk$i 2>/dev/null | grep "/dev/md" | awk '{print $4'}`

  if [ "$freespace" != "" ]

  then

      disk_free[$i]=$freespace

      totalfree=$((totalfree + $freespace))

  else

      disk_free[$i]=0

  fi

else

    disk_free[$i]=0

fi

 

#Calculate the content on the disks other than the Movies.

disk_other[$i]=$((${disk_size[$i]} - ${disk_free[$i]} - ${disk_movies[$i]}))

totalother=$(($totalother + ${disk_other[$i]}))

 

# The amount of space available on a disk = free space plus the space currently used by movies.

disk_available[$i]=$((${disk_free[$i]} + ${disk_movies[$i]}))

totalavailable=$(($totalavailable + ${disk_available[$i]}))

 

printf "#Disk %2d free=%10d movies=%10d other=%10d total=%10d available=%10d\n" \

          $i ${disk_free[$i]} ${disk_movies[$i]} ${disk_other[$i]} ${disk_size[$i]} ${disk_available[$i]}

#      disk_free[$i]=$((${disk[$i]} + $freespace))

done

 

printf "#totalfree      = %10d\n" $totalfree

printf "#totalspace      = %10d\n" $totalspace

printf "#total available = %10d\n" $totalavailable

 

 

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

do

  # determine the "percentage" of total space used by a given disk

  percentage=`awk 'BEGIN{ a=(('${disk_size[$i]}'*100)/'$totalspace'); printf "%d",  a}'`

 

  # determine how much reserve space we keep spare on the disk.

  #disk_reserve[$i]=$((($totalfree/110)*$percentage))

  disk_reserve[$i]=$((($totalfree/120)*$percentage))

 

  if [ ${disk_reserve[$i]} -gt ${disk_available[$i]} ]

  then

      disk_allocate[$i]=${disk_available[$i]}

  else

      disk_allocate[$i]=$((${disk_available[$i]} - ${disk_reserve[$i]}))

  fi

  printf "#disk %2d available = %10d reserve = %10d allocate = %10d percentage = %3d\n" $i ${disk_available[$i]} ${disk_reserve[$i]} ${disk_allocate[$i]} $percentage

 

done

 

function get_disk() {

  for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

  do

    if [ -f "/mnt/disk$i/Movies$1" ]

    then

        echo /mnt/disk$i/Movies$1

        exit

    fi

  done

  echo /mnt/diskX/Movies$1

}

 

#

# Start with disk1. Allocated

allocate_disk=1

# Step 2.  Get all the files and their sizes, in alpha order

# ISO AVI MPG nfo tbn jpg

ls -s -1 /mnt/disk*/Movies/*.[iiAaMmntj][ssVvPpfb][OoIiGgon] | sed "s/'/\\\'/g" | while read size name

do

# If not enough space, (available space is less than the size of the file) advance to the next disk

    if [ ${disk_allocate[$allocate_disk]} -lt $size ]

    then

      allocate_disk=$(($allocate_disk+1))

      if [ "${disk_allocate[$allocate_disk]}" -le 0 ]

      then

          allocate_disk=$(($allocate_disk+1))

      fi

      printf "echo \"================================ filling disk $allocate_disk =====================\"\n"

    fi

    # if the space available is greater than the size of the file, then move the file to this disk, decrement the available space

    available_space=${disk_allocate[$allocate_disk]}

echo -n "#Disk $allocate_disk has `format_number $available_space` space available,  need=`format_number $size`"

    available_space=$(($available_space - $size))

    disk_allocate[$allocate_disk]=$available_space

echo " # remaining = `format_number $available_space`"

  # name=`echo $name | sed "s/user/disk*/"`

    name=`echo $name | sed -e "s/ /\\\\\ /g" -e "s/(/\\\\\(/g" -e "s/)/\\\\\)/g" -e "s/'/\\\\\'/g" -e "s/\/mnt\/user\/Movies//"`

    #name=`echo $name | sed -e "s/ /\\\\\ /g" -e "s/user/disk*/"`

#echo "$name"

    #current_file=`ls $name`

    current_file=`get_disk "$name"`

    current_dir=`dirname "$current_file"`

    needed_space=$(($size * 1024))

    needed_space=$(($needed_space + 10000))

    # Step 3.  Allocate files to disks.

    if [ "$current_file" != "" ]

    then

      if [ "/mnt/disk$allocate_disk/Movies" != "$current_dir" ]

      then

        echo "[ \`df -B1 /mnt/disk$allocate_disk/Movies | awk '/dev/{print \$4}'\` -gt $needed_space ] && \

              $m $current_file /mnt/disk$allocate_disk/Movies/ || echo \"$current_file\" SKIPPED copy to Disk$allocate_disk"

      else

        echo "echo \"$current_file\" is on the correct disk"

      fi

    fi

done

 

The script does not actually move any of the movies, but its output is a series of commands that will move the move them.  You will need to re-direct its output to a file that you subsequently execute as a shell script.

It does remove the links in the alpha ranges, so if you already have folders named  "Movies A-D", "Movies E-J", "Movies K-O", "Movies P-S" and "Movies T-Z"

 

DO NOT RUN THIS SCRIPT if the alpha-range-directories contain the only copies of your movies.  It expects all of your movies are in the /mnt/user/Movies share.  It does NOT deal with anything other than ISO, avi, and mpg movies. 

 

If you run this and it removes all your movies... sorry.  You were warned.

 

Joe L.

  • 5 months later...

Even better than a hidden file in each root folder that specifies the split level for the subfolders....

A (hidden?) tiny file in folders which should not be split.  (nosplit.txt?)  If unRaid sees this file, it does not split the folder or any subsequent subfolders.

For example:

 

Movies <-  can split

  Aliens <- cannot split because nosplit.txt file in folder

    nosplit.txt

    BDMV <- cannot split because nosplit.txt file in parent folder

    CERTIFICATE <-cannot split....

 

While this might seem like a pain, if it's essentially an empty file and the filename is the only thing that matters, you could deploy this in almost no time depending on how many folders you have that you don't want split.

 

Of course, this could be just another silly idea on split levels.

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.