2016-11-09, 22:24
You're welcome
But here are my answers to your problem:
So here comes the customized script:
Enjoy... And I hope you can solve your special character issue.
Quote: I thought nobody would respond ever again, but now you appear!!Have some faith, man I mean it was only a day (in my time zone). As you asked so kindly, I had another look at your problems.
Quote:I dislike relying on an online connection and availability of content in databasesAs you are editing your nfo files anyway you might have a look at some of the proper library managers like Ember or Elch that - afaik - allow to edit and safe nfos as well. The script is rather meant for getting really unscrapable videos that are not in tvdb, imdb, etc. like vodcast or home made videos to show up in Kodi.
But here are my answers to your problem:
Quote:1. Problem: incompatibility with characters. "Mr. Robot" has its <title> set as "Mr",That was a bug in my script... sorry. Just had to change the two "%%~nt" into "%%t". Should work now properly.
Quote:folders with Asian characters like "スクールランブル" are skippedBeing a lousy coder I struggle with special characters, code pages and character encoding things myself. Can't really help you there. Could even be caused by the way you save the .bat file. I always get rid of special chars before I put the files into the folder.
Quote:2. Problem: some shows cannot have their name modifiedNOT renaming anything and using the orginal file name for the .nfo is actually easier than renaming it . I changed that in the code below. So no more S01E01 etc. naming. I put the episode number in the nfo file instead. I hope Kodi can work with that.
Quote:3. Suggestion: Similar to above, it'd be good to have a mechanism that detects if an .nfo already existsIt should already do that. Works here. Probably you missed something when you stripped the renaming from my code.
Quote:4. Suggestion: I'd like to use "Extra" instead of "Season 00"Oh boy... now the script really becomes custom made for you... ok, included that, too. You can also use that part for more exceptions like that, e.g. "Extras", "DVD extras", etc. Just copy the line and change the keyword.
So here comes the customized script:
Code:
@echo off & setlocal enabledelayedexpansion
chcp 1252 >NUL
REM Please change the next line. It should point to the folder that contains all of your unscrapable videos (without "\" at the end!)
REM I highly recommend to put those files in an extra folder that does not contain other "scrapable" videos as this script can't tell the difference and will create .nfo files for all folders
set "Basefolder=C:\Videos\Unscrapable Videos"
echo -------------------------------------------------------------------------------
REM Scans all main folders (series) without the subfolders (seasons).
echo Creating a tvshow.nfo for each new folder.
pushd "%Basefolder%"
for /f "delims=" %%t in ('dir /b /AD') do (
if not exist "!Basefolder!\%%t\tvshow.nfo" (
set "month=!date:~3,2!"
set "year=!date:~6,4!"
set "day=!date:~0,2!"
echo New folder "%%t" found! tvshow.nfo generated
REM Writing a basic XML structure to the tvshow.nfo just using the folder name as a title.
echo ^<^?xml version=^"1.0^" encoding=^"UTF-8^" standalone=^"yes^" ^?^> > "!Basefolder!\%%t\tvshow.nfo"
echo ^<tvshow^>^<title^>%%t^</title^>^<premiered^>!year!-!month!-!day!^</premiered^>^</tvshow^> >> "!Basefolder!\%%t\tvshow.nfo"
)
)
echo -------------------------------------------------------------------------------
REM Scans all main folders (series) without the subfolders (seasons).
echo Creating a .nfo for each new video.
for /f "delims=" %%t in ('dir /b /AD') do (
REM Go to show level
pushd "%%t"
echo %%t
for /f "tokens=1-2 delims= " %%a in ('dir /b /AD') do (
REM Setting the season number from the folder name by taking the part after the blank (e.g. "01" from "Season 01")
set "Seasonnumber=%%b"
REM On special request of user firewater ;)
if "%%a%%b"=="Extra" set "Seasonnumber=0"
REM Go to season level
pushd "%%a %%b"
for /f "delims=" %%f in ('dir /b /OD *.mkv *.avi *.flv *.mp4 *.wmv *.mov') do (
if not exist "%%~dpf_episodecounter.txt" echo 0 > "%%t\_episodecounter.txt"
if not exist "%%~dpnf.nfo" (
set /p "EpisodeCounter="<"%%~dpf\_episodecounter.txt"
set /A EpisodeCounter +=1
set "timestamp=%%~tf"
set "month=!timestamp:~3,2!"
set "year=!timestamp:~6,4!"
set "day=!timestamp:~0,2!"
if !EpisodeCounter! LSS 10 (
set "Episode=0!EpisodeCounter!"
) ELSE (
set "Episode=!EpisodeCounter!"
)
REM Echo !Episode!
if exist "%%~dpnf.jpg" (
set "thumb=%%~dpnf.jpg"
) else (
set thumb=
)
echo ^<^?xml version=^"1.0^" encoding=^"UTF-8^" standalone=^"yes^" ^?^> > "%%~dpnf.nfo"
echo ^<episodedetails^>^<title^>%%~nf^</title^>^<aired^>!year!-!month!-!day!^</aired^>^<season^>!Seasonnumber!^</season^>^<episode^>!Episode!^</episode^>^<thumb^>!thumb!^</thumb^>^</episodedetails^> >> "%%~dpnf.nfo"
echo !EpisodeCounter!>"%%~dpf\_episodecounter.txt"
)
)
cd..
)
pushd "%Basefolder%"
)
Enjoy... And I hope you can solve your special character issue.