(Previous) File Name Structured Import Script
Videos
This is how you can organise your videos into folders that correspond to the first letter of the file name. It looks like this:
-VIDEO-
--
-ABC-
-ALL-
-DEF-
-GHI-
-JKL-
-MNO-
-PQRS-
-T-
-UVW-
-XYZ-
I've given T its own folder because there seem to be a lot of videos that start with T. Also, every video goes in the -ALL- folder as well as the folder that corresponds to the first letter of its file name.
1. Make a copy of the import.js file so you can go back to it if you make a big mistake. I name mine import.js.original
2. Open the import.js file in your favourite text editor and replace the addVideo function with this:
function addVideo(obj) { // first title data var title = obj.meta[M_TITLE]; if (!title) title = obj.title; // always add to the ALL section var chain = new Array('-VIDEO-', '-ALL-'); addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER); // create a chain that matches the first letter of the file name var c = title.charAt(0); if (c == 'a' || c == 'A' || c == 'b' || c == 'B' || c == 'c' || c == 'C') { chain = new Array('-VIDEO-', '-ABC-'); } else if (c == 'd' || c == 'D' || c == 'e' || c == 'E' || c == 'f' || c == 'F') { chain = new Array('-VIDEO-', '-DEF-'); } else if (c == 'g' || c == 'G' || c == 'h' || c == 'H' || c == 'i' || c == 'I') { chain = new Array('-VIDEO-', '-GHI-'); } else if (c == 'j' || c == 'J' || c == 'k' || c == 'K' || c == 'l' || c == 'L') { chain = new Array('-VIDEO-', '-JKL-'); } else if (c == 'm' || c == 'M' || c == 'n' || c == 'N' || c == 'o' || c == 'O') { chain = new Array('-VIDEO-', '-MNO-'); } else if (c == 'p' || c == 'P' || c == 'q' || c == 'Q' || c == 'r' || c == 'R' || c == 's' || c == 'S') { chain = new Array('-VIDEO-', '-PQRS-'); } else if (c == 't' || c == 'T') { chain = new Array('-VIDEO-', '-T-'); } else if (c == 'u' || c == 'U' || c == 'v' || c == 'V' || c == 'w' || c == 'W') { chain = new Array('-VIDEO-', '-UVW-'); } else if (c == 'x' || c == 'X' || c == 'y' || c == 'Y' || c == 'z' || c == 'Z') { chain = new Array('-VIDEO-', '-XYZ-'); } else { chain = new Array('-VIDEO-', '--'); } // add the video addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER); }
3. Save your modified import.js file
4. Re-import all your video
Wishlist: I'd really like to be able to automatically re-organise the folders depending on the number of items that it contains. For example, if there were lots and lots of videos in the -ABC- folder I would like to break it up into -A-, -B-, -C- automatically. I'd also like to put the number of videos that are contained in the folder in the name of the folder; for example, -ABC (235)-. Unfortunately I don't think this is possible without some big changes to mediatomb.
Album
This is how you can organise your music albums into folders that correspond to the first letter of the file name. It looks like this:
-ALBUMS-
--
-0-9-
123ALBUM
-ABC-
A-ALBUM
B-ALBUM
C-ALBUM
-DEF-
D-ALBUM
...
-GHI-
-JKL-
-MNO-
-PQRS-
-TUVW-
-XYZ-
To do this, you have to comment out this in your import.js:
// chain = new Array('Audio', 'Albums', album); // obj.title = track + title; // addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);
and replace it with:
// create a chain that matches the first letter of the file name var c = album.charAt(0); if (c == 'a' || c == 'A' || c == 'b' || c == 'B' || c == 'c' || c == 'C') { chain = new Array('Audio', 'Albums', '-ABC-', album); } else if (c == 'd' || c == 'D' || c == 'e' || c == 'E' || c == 'f' || c == 'F') { chain = new Array('Audio', 'Albums', '-DEF-', album); } else if (c == 'g' || c == 'G' || c == 'h' || c == 'H' || c == 'i' || c == 'I') { chain = new Array('Audio', 'Albums', '-GHI-', album); } else if (c == 'j' || c == 'J' || c == 'k' || c == 'K' || c == 'l' || c == 'L') { chain = new Array('Audio', 'Albums', '-JKL-', album); } else if (c == 'm' || c == 'M' || c == 'n' || c == 'N' || c == 'o' || c == 'O') { chain = new Array('Audio', 'Albums', '-MNO-', album); } else if (c == 'p' || c == 'P' || c == 'q' || c == 'Q' || c == 'r' || c == 'R' || c == 's' || c == 'S') { chain = new Array('Audio', 'Albums', '-PQRS-', album); } else if (c == 't' || c == 'T' || c == 'u' || c == 'U' || c == 'v' || c == 'V' || c == 'w' || c == 'W') { chain = new Array('Audio', 'Albums', '-TUVW-', album); } else if (c == 'x' || c == 'X' || c == 'y' || c == 'Y' || c == 'z' || c == 'Z') { chain = new Array('Audio', 'Albums', '-XYZ-', album); } else if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0') { chain = new Array('Audio', 'Albums', '-0-9-', album); } else { chain = new Array('Audio', 'Albums', '--', album); } addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER);
Artists
This is how you can organise your music artists into folders that correspond to the first letter of the file name. This is a bit more complex because every artist has some subfolders. It looks like this:
-ARTISTS-
--
-0-9-
123ARTIST
All - full name
All songs
ALBUM1
ALBUM2
-ABC-
A-ARTIST
...
B-ARTIST
...
-DEF-
-GHI-
-JKL-
-MNO-
-PQRS-
-TUVW-
-XYZ-
To do this, you have to comment out three parts of your import.js:
// chain = new Array('Audio', 'Artists', artist, album); // obj.title = track + title; // addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC_ALBUM);
// chain = new Array('Audio', 'Artists', artist, 'All - full name'); // addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
// chain = new Array('Audio', 'Artists', artist, 'All Songs'); // addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER_MUSIC);
Now you can replace the code with this:
// 4 - Artists var c = artist.charAt(0); if (c == 'a' || c == 'A' || c == 'b' || c == 'B' || c == 'c' || c == 'C') { chain = new Array('Audio', 'Artists', '-ABC-', artist); } else if (c == 'd' || c == 'D' || c == 'e' || c == 'E' || c == 'f' || c == 'F') { chain = new Array('Audio', 'Artists', '-DEF-', artist); } else if (c == 'g' || c == 'G' || c == 'h' || c == 'H' || c == 'i' || c == 'I') { chain = new Array('Audio', 'Artists', '-GHI-', artist); } else if (c == 'j' || c == 'J' || c == 'k' || c == 'K' || c == 'l' || c == 'L') { chain = new Array('Audio', 'Artists', '-JKL-', artist); } else if (c == 'm' || c == 'M' || c == 'n' || c == 'N' || c == 'o' || c == 'O') { chain = new Array('Audio', 'Artists', '-MNO-', artist); } else if (c == 'p' || c == 'P' || c == 'q' || c == 'Q' || c == 'r' || c == 'R' || c == 's' || c == 'S') { chain = new Array('Audio', 'Artists', '-PQRS-', artist); } else if (c == 't' || c == 'T' || c == 'u' || c == 'U' || c == 'v' || c == 'V' || c == 'w' || c == 'W') { chain = new Array('Audio', 'Artists', '-TUVW-', artist); } else if (c == 'x' || c == 'X' || c == 'y' || c == 'Y' || c == 'z' || c == 'Z') { chain = new Array('Audio', 'Artists', '-XYZ-', artist); } else if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0') { chain = new Array('Audio', 'Artists', '-0-9-', artist); } else { chain = new Array('Audio', 'Artists', '--', artist); } obj.title = track + title; addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER); // 4.1 - Artists / All - Full Name var c = artist.charAt(0); if (c == 'a' || c == 'A' || c == 'b' || c == 'B' || c == 'c' || c == 'C') { chain = new Array('Audio', 'Artists', '-ABC-', artist, 'All - full name'); } else if (c == 'd' || c == 'D' || c == 'e' || c == 'E' || c == 'f' || c == 'F') { chain = new Array('Audio', 'Artists', '-DEF-', artist, 'All - full name'); } else if (c == 'g' || c == 'G' || c == 'h' || c == 'H' || c == 'i' || c == 'I') { chain = new Array('Audio', 'Artists', '-GHI-', artist, 'All - full name'); } else if (c == 'j' || c == 'J' || c == 'k' || c == 'K' || c == 'l' || c == 'L') { chain = new Array('Audio', 'Artists', '-JKL-', artist, 'All - full name'); } else if (c == 'm' || c == 'M' || c == 'n' || c == 'N' || c == 'o' || c == 'O') { chain = new Array('Audio', 'Artists', '-MNO-', artist, 'All - full name'); } else if (c == 'p' || c == 'P' || c == 'q' || c == 'Q' || c == 'r' || c == 'R' || c == 's' || c == 'S') { chain = new Array('Audio', 'Artists', '-PQRS-', artist, 'All - full name'); } else if (c == 't' || c == 'T' || c == 'u' || c == 'U' || c == 'v' || c == 'V' || c == 'w' || c == 'W') { chain = new Array('Audio', 'Artists', '-TUVW-', artist, 'All - full name'); } else if (c == 'x' || c == 'X' || c == 'y' || c == 'Y' || c == 'z' || c == 'Z') { chain = new Array('Audio', 'Artists', '-XYZ-', artist, 'All - full name'); } else if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0') { chain = new Array('Audio', 'Artists', '-0-9-', artist, 'All - full name'); } else { chain = new Array('Audio', 'Artists', '--', artist, 'All - full name'); } addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER); // 4.2 - Artists / All Songs var c = artist.charAt(0); if (c == 'a' || c == 'A' || c == 'b' || c == 'B' || c == 'c' || c == 'C') { chain = new Array('Audio', 'Artists', '-ABC-', artist, 'All Songs'); } else if (c == 'd' || c == 'D' || c == 'e' || c == 'E' || c == 'f' || c == 'F') { chain = new Array('Audio', 'Artists', '-DEF-', artist, 'All Songs'); } else if (c == 'g' || c == 'G' || c == 'h' || c == 'H' || c == 'i' || c == 'I') { chain = new Array('Audio', 'Artists', '-GHI-', artist, 'All Songs'); } else if (c == 'j' || c == 'J' || c == 'k' || c == 'K' || c == 'l' || c == 'L') { chain = new Array('Audio', 'Artists', '-JKL-', artist, 'All Songs'); } else if (c == 'm' || c == 'M' || c == 'n' || c == 'N' || c == 'o' || c == 'O') { chain = new Array('Audio', 'Artists', '-MNO-', artist, 'All Songs'); } else if (c == 'p' || c == 'P' || c == 'q' || c == 'Q' || c == 'r' || c == 'R' || c == 's' || c == 'S') { chain = new Array('Audio', 'Artists', '-PQRS-', artist, 'All Songs'); } else if (c == 't' || c == 'T' || c == 'u' || c == 'U' || c == 'v' || c == 'V' || c == 'w' || c == 'W') { chain = new Array('Audio', 'Artists', '-TUVW-', artist, 'All Songs'); } else if (c == 'x' || c == 'X' || c == 'y' || c == 'Y' || c == 'z' || c == 'Z') { chain = new Array('Audio', 'Artists', '-XYZ-', artist, 'All Songs'); } else if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0') { chain = new Array('Audio', 'Artists', '-0-9-', artist, 'All Songs'); } else { chain = new Array('Audio', 'Artists', '--', artist, 'All Songs'); } addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER); // 4.3 - Artists / Album var c = artist.charAt(0); if (c == 'a' || c == 'A' || c == 'b' || c == 'B' || c == 'c' || c == 'C') { chain = new Array('Audio', 'Artists', '-ABC-', artist, album); } else if (c == 'd' || c == 'D' || c == 'e' || c == 'E' || c == 'f' || c == 'F') { chain = new Array('Audio', 'Artists', '-DEF-', artist, album); } else if (c == 'g' || c == 'G' || c == 'h' || c == 'H' || c == 'i' || c == 'I') { chain = new Array('Audio', 'Artists', '-GHI-', artist, album); } else if (c == 'j' || c == 'J' || c == 'k' || c == 'K' || c == 'l' || c == 'L') { chain = new Array('Audio', 'Artists', '-JKL-', artist, album); } else if (c == 'm' || c == 'M' || c == 'n' || c == 'N' || c == 'o' || c == 'O') { chain = new Array('Audio', 'Artists', '-MNO-', artist, album); } else if (c == 'p' || c == 'P' || c == 'q' || c == 'Q' || c == 'r' || c == 'R' || c == 's' || c == 'S') { chain = new Array('Audio', 'Artists', '-PQRS-', artist, album); } else if (c == 't' || c == 'T' || c == 'u' || c == 'U' || c == 'v' || c == 'V' || c == 'w' || c == 'W') { chain = new Array('Audio', 'Artists', '-TUVW-', artist, album); } else if (c == 'x' || c == 'X' || c == 'y' || c == 'Y' || c == 'z' || c == 'Z') { chain = new Array('Audio', 'Artists', '-XYZ-', artist, album); } else if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0') { chain = new Array('Audio', 'Artists', '-0-9-', artist, album); } else { chain = new Array('Audio', 'Artists', '--', artist, album); } addCdsObject(obj, createContainerChain(chain), UPNP_CLASS_CONTAINER);
News Feed