bwh wrote:...when I sometimes delete a few of the movies
the associated files don't necessarily get deleted.
So I have some "orphaned"
lovely_movie.jpg
lovely_movie.nfo
files even if te lovely_movie.mkv has been deleted.
Here a simple batch for that task.
For each X.jpg,... if Not X.mks existent,... Delete X.jpg
For each X.nfo,... if Not X.mks existent,... Delete X.nfo
Code: Select all
@ECHO OFF
GoTo START
-------------------
Hulk.jpg
Hulk.nfo
Hulk.mkv
-------------------
Spiderwomen 2.jpg
Spiderwomen 2.nfo
-------------------
Die Brücke 3.jpg
Die Brücke 3.nfo
Die Brücke 3.mkv
-------------------
Der Ölprinz 4.jpg
Der Ölprinz 4.nfo
-------------------
:START
REM For each X.jpg, if Not X.mks exists, Delete X.jpg
REM For each X.nfo, if Not X.mks exists, Delete X.nfo
setLocal EnableDelayedExpansion
For /f "delims=" %%F in ('dir /B *.jpg') Do (
SET BASE=%%~nF
IF NOT EXIST "!BASE!.mkv" (ECHO DEL "%%F")
)
For /f "delims=" %%F in ('dir /B *.NFO') Do (
SET BASE=%%~nF
IF NOT EXIST "!BASE!.mkv" (ECHO DEL "%%F")
)
PAUSE
GoTo :EOF
-------------------
Result:
c:\temp\TCTemp\5>Find-Delete-Orphans.cmd
DEL "Der Ölprinz 4.jpg"
DEL "Spiderwomen 2.jpg"
DEL "Der Ölprinz 4.nfo"
DEL "Spiderwomen 2.nfo"
c:\temp\TCTemp\5>
-------------------
Or...
Collect all Orphans in a text file and utilize than cm_LoadSelectionFromFile=2032;Read file selection from file
Code: Select all
@ECHO OFF
SET FileList=aaaaaa_Orphans.txt
IF EXIST %FileList% DEL %FileList%
CHCP 1252
setLocal EnableDelayedExpansion
For /f "delims=" %%F in ('dir /B *.jpg') Do (
SET BASE=%%~nF
IF NOT EXIST "!BASE!.mkv" (ECHO %%F>> %FileList%)
)
For /f "delims=" %%F in ('dir /B *.NFO') Do (
SET BASE=%%~nF
IF NOT EXIST "!BASE!.mkv" (ECHO %%F>> %FileList%)
)
NOTEPAD %FileList%
ECHO In TC use cm_LoadSelectionFromFile=2032;Read file selection from file
ECHO Perhaps followed by cm_ShowOnlySelected ? (See TOTALCMD.INC file for more)
PAUSE
"aaaaaa_Orphans.txt" contains now:
Der Ölprinz 4.jpg
Spiderwomen 2.jpg
Der Ölprinz 4.nfo
Spiderwomen 2.nfo
Usage:
Execute the batch in your folder with movies.
Paste cm_LoadSelectionFromFile in TC command line, select aaaaaa_Orphans.txt.
Result: all orphaned files are selected now.
- - -
milo1012's selection trick works well too.
I have played around a bit and added another EM_cmd in my usercmd.ini:
[
em_MKV]
cmd=
SelectfilesU *.mkv *.mp4 *.avi>*.jpg *.nfo
Now
select all files in the movie folder
first,
next execute
em_MKV in TC command line,
and done, only orphaned files are selected (but unrelated files too if there are any

).
Help wrote:14. SELECTFILES file types marks files of the given type, e.g. SELECTFILES *.txt *.doc
Supported modifiers:
D=only folders, B=both, U=unselect,
L=left side, R=right side, T=target panel,
S=Reverts whether just files or files+folders are selected when Shift is pressed during execution.