Last active
November 1, 2023 17:41
-
-
Save psitem/77ac095ded4d84ba3479 to your computer and use it in GitHub Desktop.
My naive Batch script for moving Television torrents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
GOTO :TheLoop | |
:TheFile | |
FOR /F "tokens=1-7 delims=. " %%a in (%1) do ( | |
IF EXIST "\\server\tv\%%a %%b %%c %%d %%e %%f %%g" CALL :MoveFile %1 "\\server\tv\%%a %%b %%c %%d %%e %%f %%g\" & GOTO :EOF | |
IF EXIST "\\server\tv\%%a %%b %%c %%d %%e %%f" CALL :MoveFile %1 "\\server\tv\%%a %%b %%c %%d %%e %%f\" & GOTO :EOF | |
IF EXIST "\\server\tv\%%a %%b %%c %%d %%e" CALL :MoveFile %1 "\\server\tv\%%a %%b %%c %%d %%e\" & GOTO :EOF | |
IF EXIST "\\server\tv\%%a %%b %%c %%d" CALL :MoveFile %1 "\\server\tv\%%a %%b %%c %%d\" & GOTO :EOF | |
IF EXIST "\\server\tv\%%a %%b %%c" CALL :MoveFile %1 "\\server\tv\%%a %%b %%c\" & GOTO :EOF | |
IF EXIST "\\server\tv\%%a %%b" CALL :MoveFile %1 "\\server\tv\%%a %%b\" & GOTO :EOF | |
IF EXIST "\\server\tv\%%a" CALL :MoveFile %1 "\\server\tv\%%a\" & GOTO :EOF | |
REM Move items in subdirectories to the parent so that the subdirectory can be removed. | |
MOVE %1 %~dp0 > NUL 2>&1 | |
) | |
GOTO :EOF | |
:MoveFile | |
ECHO Move: %1 %2 | |
MOVE /Y %1 %2 > NUL 2>&1 | |
ECHO Moved. | |
GOTO :EOF | |
:InnerLoop | |
FOR /F "delims=" %%i in ('dir *.avi *.mkv *.mp4 *.srt /b 2^>NUL') DO ( | |
Call :TheFile "%%i" | |
) | |
GOTO :EOF | |
:TheLoop | |
REM Process files in current directory. | |
CALL :InnerLoop | |
REM Process files in subdirectories and remove the subdirectories. | |
for /d %%d in (*) do ( | |
PUSHD %%d | |
CALL :InnerLoop | |
POPD | |
ECHO Removing Directory: %%d | |
rd "%%d" /s /q | |
) | |
TIMEOUT /T 10 > NUL | |
GOTO :TheLoop | |
GOTO :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the age of Sonarr, this script has been obsolete for years and is left here for historical purposes.