nested mess
Posted: 10 May 2013 00:47
i tried combining new code to original batch. what i assumed would be a simple condition test for %1 and if true run 1 section, else run nother. nah not that simple!
Code: Select all
@@cls
@ECHO Off
COLOR 0e
if "%~1" == "" (
IF not EXIST NFO2DIR2.TXT (
ECHO Ensure your've read nfo2dir2.txt before you run, Press ^^C if you want to abort. .
echo Because WARNING: This will irreversibly, alter disk structure!!!
ping localhost -n 5 >nul
) else (
START /max notepad NFO2DIR2.TXT
)
if not exist *.nfo (
ECHO It appears you haven't run vid. export yet!
ping localhost -n 5 >nul
exit /B
)
echo.
echo Stacked video files MAY be present, run with
echo commandline next, continuing anyway. .
ping localhost -n 5 >nul
for %%a in (*.nfo) do md "%%~na" & move /y "%%~na.*" "%%~na" & move /y "%%~na-fanart.*" "%%~na" & move /y "%
%~na-poster.*" "%%~na" & move /y "%%~na-thumb.*" "%%~na" & move /y "%%~na-landscape.*" "%%~na" 2 >nul
echo.
echo Please wait. . DON'T INTERRUPT!!
ping localhost -n 5 >nul
if EXIST extrathumbs (
rd /s /q extrathumbs
)
if EXIST extrafanart (
rd /s /q extrafanart
echo.
echo extrafanart and extrathumbs dir. deleted
) ELSE (
echo.
echo extrafanart or extrathumbs dir. not found. . .
:end
echo.
echo The following is a listing of files not yet processed
echo It doesn't show your newly created dir. structure!. . .
echo.
dir /a-d-h
ping localhost -n 3 >nul
::@cls
echo.
ECHO +--------------------------------+
ECHO :XBMC NFO TO DIR Creator V2.50. :
ECHO :(c)2012,2013, by the 'Strokeman':
ECHO +--------------------------------+
ECHO.
echo Operation Completed Successfully, you will now have to update Library, After
echo that, please run artwork downloader, then enable extrafanart in chosen skin.
echo.
echo Rogue or orphan stacked files?. . .Run nfo2dir2 with commandline.
ping localhost -n 5 >nul
) ELSE (
@Echo OFF
Color 0b
REM Part of the file name, will be replaced with %~1 to take input from cmd
SET "InFilePartName=%~1"
SET "MaxFiles=%~2" // Default Max Files in sequence is 10
REM Check for user input
IF "%~1" == "" Goto :Error
IF "%~2" == "" SET "MaxFiles=10" // Default max files will be set to 10 if no input was found
Rem The Following is executed when there is input from user
SET "PartName=%InFilePartName:~0,-1%" // This is the name without the last number
SET "PartNum1=%InFilePartName:~-1%" // Remove This Line if The parts always start with number 1
For /L %%A In ( 1 1 %MaxFiles% ) Do (
IF Exist "*%PartName%%%A*" (
CALL :ProcessFiles "%PartName%" "%%A"
)
)
)
REM After It finish it will Display the following and exit
cls
Echo.
Echo +-------------------------------------------+
Echo : Rogue 'n' orphan stacked file mover v1.50 :
Echo : A NFO2DIR2 companion (c)2013, 'Strokeman' :
Echo +-------------------------------------------+
Echo.
Echo.
Echo COMPLETED..Directory(s) created and all related files (IF ANY), moved...
GOTO :EOF
Exit
:ProcessFiles
SET "InputName=%~1"
SET "InputNum=%~2"
SETLOCAL EnableDelayedExpansion
For /F "delims=" %%A In (' DIR /B /A:-D "*%InputName%%InputNum%.*" ') Do (
IF Exist "%%A" (
SET "FName=%%~nA"
SET "FNameExt=%%~nxA"
SET "FullFName=%%~dpnxA"
For /F "tokens=1 delims=-.#(" %%z In ( "!FName!" ) Do SET "DirName=%%z"
IF NOT EXIST "!DirName!" MD "!DirName!" >NUL
IF EXIST "!FullFName!" MOVE "!FullFName!" "%%~dpA!DirName!\" >NUL
IF EXIST "%%~dpA!DirName!*-fanart.*" MOVE "%%~dpA!DirName!**-fanart.*" "%%~dpA!DirName!\" >NUL
IF EXIST "%%~dpA!DirName!*-poster.*" MOVE "%%~dpA!DirName!**-poster.*" "%%~dpA!DirName!\" >NUL
IF EXIST "%%~dpA!DirName!*-thumb.*" MOVE "%%~dpA!DirName!**-thumb.*" "%%~dpA!DirName!\" >NUL
IF EXIST "%%~dpA!DirName!*-landscape.*" MOVE "%%~dpA!DirName!**-landscape.*" "%%~dpA!DirName!\" >NUL
) Else (
Echo No files found that match. .
ping localhost -n 5 >nul
)
)
gOTO :EOF
:Error
Echo None, or incorrect commandline given. . .exiting with no changes. .
Echo Syntax:clean stackseparator eg. "clean -cd1", "clean disk1"
Echo If orphaned files remain, you may need to manually move.
GOTO :EOF
)