Frodo - Create multiple stub files from single source text input file
#1
Rainbow 
Hi there. I'm relatively new to the XBMC Community and HTPC configuration in general, however I've installed and configured the Frodo (RC3 Confluence) over a NextPVR (2.5.9 R2) backend over the last couple of weeks - Windows 8 Pro 64 bit. Extremely impressed with all of the the inherent power and functionality, not to mention the visual experience! I have even managed to get the Official XBMC Android Remote up and running (v1.0.9) - cool stuff!

I want to now incorporate my offline physical DVD collection into the XBMC Library, since it will take much time to create iso's or otherwise transcode them. I have over 400 dvd's for which I need to create (write to directory) the media stub files for, in order to incorporate the titles into my Home Theatre PC along with my other media (which I've done). I know the stubs are essentially empty text files that will need to be created under two specific naming conventions. The first is for movies " C:Users\Public\Movies\moviename.dvd.disc " and the second is for TV Series sets stored in a season-episode format like " C:Users\Public\tvseriesname\s01-e01-02-03-04.dvd.disc ". I've already created and implemented some manually as a Proof of Concept detailed in the Wiki, successfully. I couldn't imagine doing all 400 or so manually within my lifetime, lol.

So, I have created a csv text file encompassing the entire list of the respective media stub files to be created, hoping to run a batch-mode creation process against. After going through all of the documentation and searched/reviewed threads here and elsewhere, the closest I've been able to get is within the Wiki referenced 3rd party BRU (Bulk Rename Utility) software environment in the "Import and Rename In Pairs" function. Close but not enough. Is there a way to accomplish this or does anyone know of a script or software platform that they could point me towards.

Thanks in advance!
Reply
#2
This could easily be done with a batch file. You just need the "for /f" command to parse your file and go through each line.

If you need help with that, please post the 1st 5 lines of your csv file along with an explanation of what each column represents and i'll see if i can whip up something for you.

-Pr.

Actually to be sure stuff works as it should, make sure you post enough of the csv to cover 5 different folders... Not just 1 folder with 5 episodes. The best would be 5 movies and 5 TV series.
------------------------------------------
[4 Kodi Clients + 4 Norco RPC-4224 Media Servers w/237 TB HDD Space]
Reply
#3
Ok it's pretty slow at work so i decided to see how many lines are needed to get this working Smile

You will need to create 3 files to get this working (well 2 not including your csv file)

The actual code you need to run can be saved in a .bat or .cmd file

dummytv.cmd
Code:
@Echo off
for /F "tokens=1,2 delims=," %%l in (offline_media.csv) do (
IF NOT EXIST %%l md "%%l"
copy /y dummy.dvd "%%l\%%m"
)

So, an explanation of what is going on...

We are telling the script to open up the file called offline_media.csv and look for the 1st and 2nd things that are delimited by a comma.
The 1st thing it finds will be stored in %%l and the 2nd thing it finds should be stored in the next letter up which is %%m
The 1st token is the Folder and the 2nd is the filename

It will then check to see if the folder exists and if it doesn't it creates it. It then proceeds to copy our dummy.dvd stub file as the filename from the csv

Rinse and repeat until the end of file.

As you can see, extremely simple.

So, to get this working :
  • Save the code into dummytv.cmd
  • Create an empty or very small dummy.dvd file
  • Put them in the root of the directory you wish to populate
  • Add your offline_media.csv file
  • Run dummytv.cmd

Your offline_media.csv should look kinda like this :
Code:
Ally McBeal\Season 1,Ally McBeal - 1x01 - Pilot - SD DVD.dvd
Ally McBeal\Season 1,Ally McBeal - 1x02 - Compromising Positions - SD DVD.dvd
Ally McBeal\Season 1,Ally McBeal - 1x03 - The Kiss - SD DVD.dvd
Ally McBeal\Season 2,Ally McBeal - 1x04 - The Affair - SD DVD.dvd
Ally McBeal\Season 3,Ally McBeal - 1x05 - One Hundred Tears Away - SD DVD.dvd
Ally McBeal\Season 4,Ally McBeal - 1x06 - The Promise - SD DVD.dvd
Ally McBeal\Season 5,Ally McBeal - 1x07 - The Attitude - SD DVD.dvd
Angels In America,Angels In America - 1x01 - 1x02 - 1x03 - SD DVD.dvd
Angels In America,Angels In America - 1x04 - 1x05 - 1x06 - SD DVD.dvd
Big Love\Season 3,Big Love - 3x01 - Block Party - SD TV.dvd
Big Love\Season 3,Big Love - 3x02 - Empire - SD TV.dvd
Big Love\Season 3,Big Love - 3x03 - Prom Queen - SD TV.dvd
Big Love\Season 3,Big Love - 3x04 - On Trial - SD TV.dvd
Big Love\Season 3,Big Love - 3x05 - For Better or for Worse - SD TV.dvd
Canterbury's Law,Canterbury's Law - 1x01 - Pilot - SD TV.dvd
Canterbury's Law,Canterbury's Law - 1x02 - Baggage - SD TV.dvd
Canterbury's Law,Canterbury's Law - 1x03 - What Goes Around - SD TV.dvd
Canterbury's Law,Canterbury's Law - 1x04 - Sweet Sixteen - SD TV.dvd
Canterbury's Law,Canterbury's Law - 1x05 - Trade-Off - SD TV.dvd

I am sure you can figure out how this file should look for Movies now Smile

HTH

-Pr.
------------------------------------------
[4 Kodi Clients + 4 Norco RPC-4224 Media Servers w/237 TB HDD Space]
Reply
#4
Man, this is awesome, and simple too! Thanks for this. I need a little time later this evening when the house quiets down, to fully wrap my head around a couple small things I would like to incorporate into the execution. One for example is, in my csv file, I allowed for a variable message component which is supported in the media disc stub file, which pops up with the "Insert ~movietitle~ into the DVD Drive" OSD prompt. The variable part is simply a reference to "Season #, Disk #" of the DVD set. I could easily add another token to your script to read it, however I need to learn the Command Syntax in order to append this within the media stub to store it. I'll check back later tonight when all is quiet.

Thanks again.
Reply
#5
Ask and you shall receive Big Grin

Code:
@Echo off
for /F "tokens=1,2,3 delims=," %%l in (offline_media.csv) do (
IF NOT EXIST %%l md "%%l"
Echo ^<discstub^> >dummy.txt
Echo    ^<message^>%%n^</message^> >>dummy.txt
Echo ^</discstub^> >>dummy.txt
copy /y dummy.txt "%%l\%%m"
)

Make sure there are no commas in your third token. So instead of

Quote:Please insert Breaking Bad Season 3, Disc 1

Make it

Quote:Please insert Breaking Bad Season 3 - Disc 1

Or change the separator in your csv to something else like ; and use

Code:
delims=;"

-Pr.
------------------------------------------
[4 Kodi Clients + 4 Norco RPC-4224 Media Servers w/237 TB HDD Space]
Reply
#6
I apologize for bringing you down to my level, but this helps me keep track. Wink

Here is an extract of the offline_media.csv file I've created for TV Series only. Note that at this point I don't have the descriptive episode names until the files are actually parsed. XBMC is manging the names for me so the naming convention isn't so important anyway. However the s01e01-02-03etc.dvd.disc minimizes the quantity of files stored and seems best suited for the 4 to 6 episodes per disc anyway. Below the csv extract is a simplistic presentation of the scripting concept and desired outcome.

Code:
Headers for clarity ->TV Series (DirectoryName), Season (SubDirectory Name), Episodes (Filename), Disc (MessageTextRef)

Criminal Minds,1,01-02-03-04,1
Criminal Minds,1,05-06-07-08,2
Criminal Minds,1,09-10-11-12,3
Criminal Minds,1,13-14-15-16,4
Criminal Minds,1,17-18-19-20,5
Criminal Minds,1,21-22,6
Criminal Minds,2,01-02-03-04,1
Criminal Minds,2,05-06-07-08,2
Criminal Minds,2,09-10-11-12,3
Criminal Minds,2,13-14-15-16,4
Criminal Minds,2,17-18-19-20,5
Criminal Minds,2,21-22-23,6

Media Disc Stub would look like -> Criminal Minds\Season 1\s01e01-02-03-04.dvd.disc  

  Code Expression built with Token Ref's and inserted text -> TV Series (DirectoryName) + "Season " + Season (SubDirectoryName) + "s" + Season (SubDirectoryName) + "e" + Episodes (Filename) + "dvd.disc"

Embedded variable message in file would look like this -> "from Season 1 - Disc 1"

  Code Expression "from Season " +  Season (SubDirectory Name) + "Disc " + Disc (MessageTextRef)

...and that's where I need your help with the code. Is this doable and am I asking for too much? I could re-do the csv file to incorporate the fully built expressions, but where would the efficiency be in that? Laugh I'm hoping it is the most efficient and re-useable for others to implement. I will document the process and I'm happy to pass along with your efforts to the Wiki Editor's for the User/HowTo Manual assuming your ok with that.
Reply
#7
Yes of course i have no problem with that at all... For so long i was part of a forum group that prevented people from adding to my reputation that i am now trying to catch up Tongue

But seriously i love XBMC so if i can contribute something to the wiki then that's great...

Now i do understand what you want your stubs to be named as but not exactly sure what you wish the insert disc message to be... You seem to have the Season twice in there...

So from the 1st Criminal Minds, what should the message say when trying to play it? If you just tell me the exact end result, i can fix up something for you in the next 10 minutes.

-Pr.
------------------------------------------
[4 Kodi Clients + 4 Norco RPC-4224 Media Servers w/237 TB HDD Space]
Reply
#8
Cool, really appreciate this, and I know what you mean.

By default XBMC has a base message "Please insert the following disc: Episode Name

The second line is optional and I would like it say: Located on Disc 1 from the Season 1 collection.

Thanks.
Reply
#9
Ah i see...

This should do the trick :

Code:
@Echo off
for /F "tokens=1,2,3,4 delims=," %%l in (offline_media.csv) do (
IF NOT EXIST %%l md "%%l"
IF NOT EXIST "%%l\Season %%m" md "%%l\Season %%m"
Echo ^<discstub^> >dummy.txt
Echo    ^<message^>Located on Disc %%o from the Season %%m collection^</message^> >>dummy.txt
Echo ^</discstub^> >>dummy.txt
copy /y dummy.txt "%%l\Season %%m\s0%%me%%n.dvd.disc"
)
------------------------------------------
[4 Kodi Clients + 4 Norco RPC-4224 Media Servers w/237 TB HDD Space]
Reply
#10
Excellent.

I'm setting this up now to run the small csv sample.
Will let you know outcome shortly, assuming you'll still be up.
Reply
#11
I'll be up for at least another hour! Let me know!
------------------------------------------
[4 Kodi Clients + 4 Norco RPC-4224 Media Servers w/237 TB HDD Space]
Reply
#12
Nod

Works perfectly!
I am so happy now... Really nice work.
Now, I'll roll it out to the other 400-500 dvd titles I have... Shouldn't take more than a minute!

Big Grin

Thanks man!
I will endorse you.

GE
Reply
#13
Glad i could help!
------------------------------------------
[4 Kodi Clients + 4 Norco RPC-4224 Media Servers w/237 TB HDD Space]
Reply
#14
(2013-02-16, 08:30)Pr.Sinister Wrote: Glad i could help!

Hi Pr.Sinister, could you tell me how to create stub files from a CSV file where entries look like this?

2019-11-02,Mean Streets,1973,https://letterboxd.com/film/mean-streets/
2019-11-02,Alice Doesn't Live Here Anymore,1974,https://letterboxd.com/film/alice-doesnt-live-here-anymore/
2019-11-02,Taxi Driver,1976,https://letterboxd.com/film/taxi-driver/
2019-11-02,"New York, New York",1977,https://letterboxd.com/film/new-york-new-york/
2019-11-02,Raging Bull,1980,https://letterboxd.com/film/raging-bull/
2019-11-02,The King of Comedy,1982,https://letterboxd.com/film/the-king-of-comedy/
Reply
 
Thread Rating:
  • 1 Vote(s) - 5 Average



Logout Mark Read Team Forum Stats Members Help
Frodo - Create multiple stub files from single source text input file51
This forum uses Lukasz Tkacz MyBB addons.