Last active
July 16, 2017 19:02
-
-
Save tip2tail/4be77c3b949ab8882ed4eb7df2997600 to your computer and use it in GitHub Desktop.
Batch file to kill qBittorrent, run a rename script and then restart qBittorrent - work-around for file lock issues
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 | |
REM ======================================================================== | |
REM tip2tail qBittorrent Kill/Rename/Restart | |
REM ======================================================================== | |
REM by Mark Young [ tip2tail ] | |
REM ======================================================================== | |
REM Last Modified: 14th July 2017 | |
REM ======================================================================== | |
REM Use command in qBittorrent (Run external program on completion): | |
REM C:\path\to\script\t2tMoveScript.bat "%F" | |
REM ======================================================================== | |
REM ======================================================================== | |
REM Initial setup - do not ammend | |
REM ======================================================================== | |
SETLOCAL ENABLEEXTENSIONS | |
SET me=%~n0 | |
SET parent=%~dp0 | |
REM ======================================================================== | |
REM Variables | |
REM ======================================================================== | |
REM Change the values below to suit your system | |
REM ======================================================================== | |
SET pathMusic="H:/Music/{n}/{album}/{pi.pad(2)+' - '}{artist} - {t}" | |
SET pathMovies="F:/Libraries/Videos/Movies/{n} ({y})" | |
SET pathTV="E:/Libraries/Videos/TV/{n}/Season {s}/{n} - {s00e00} - {t}" | |
REM Note: Add one to the required delay - i.e. 11 would be a 10 second delay | |
SET sleepDelaySeconds=11 | |
REM ======================================================================== | |
REM ======================================================================== | |
REM The content below here should not need to be changed | |
REM ======================================================================== | |
REM AMC files | |
SET pathExclude=%parent%filebot_exclude.txt | |
SET pathLogFile=filebot_amc.log | |
REM Get the date stuff sorted for logging | |
SET dateDay=%Date:~0,2% | |
SET dateMonth=%Date:~3,2% | |
SET dateYear=%Date:~6,4% | |
REM Set the log file path | |
SET pathLogDir=%parent%%dateYear%\%dateMonth%\ | |
IF NOT EXIST %pathLogDir% MKDIR %pathLogDir% | |
SET pathLog=%pathLogDir%%pathLogFile% | |
REM ======================================================================== | |
REM Find qBittorrent process path and PID | |
REM ======================================================================== | |
for /f "skip=1 tokens=*" %%a in ( | |
'wmic process where "name='qbittorrent.exe'" get ExecutablePath' | |
) do if not defined qbExePath set qbExePath=%%a | |
for /f "skip=1 tokens=*" %%a in ( | |
'wmic process where "name='qbittorrent.exe'" get ProcessID' | |
) do if not defined qbPID set qbPID=%%a | |
REM ECHO Path is - %qbExePath% | |
REM ECHO PID is - %qbPID% | |
REM ======================================================================== | |
REM Kill qBittorrent Process | |
REM ======================================================================== | |
TASKKILL /F /PID %qbPID% | |
REM ======================================================================== | |
REM Sleep to allow qbittorrent to close and release handles on files | |
REM ======================================================================== | |
PING 127.0.0.1 -n %sleepDelaySeconds% > nul | |
REM ======================================================================== | |
REM Call the renaming script | |
REM ======================================================================== | |
filebot -script fn:amc --log all --def movieFormat=%pathMovies% --def seriesFormat=%pathTV% --def musicFormat=%pathMusic% --log-file %pathLog% --action move --conflict override -non-strict --def music=y artwork=n excludeList=%pathExclude% %1 | |
REM ======================================================================== | |
REM Relaunch qBittorrent | |
REM ======================================================================== | |
START "" "%qbExePath%" | |
REM ======================================================================== | |
REM Done! | |
REM ======================================================================== | |
EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment