My goal is to delete a file named Open Notebook.onetoc2 in all folders and subfolders of Z:
drive, BUT NOT delete that file from those folders, which contain *.one
files (actual OneNote files).
I have searched for solutions online for that matter, but have not found that and do not know, how to build one such command myself exactly.
I have got this far:
for /F "delims=" %a in ('dir /b /s "Open Notebook.onetoc2"') do @if exist %~da%~pa*.one echo del: "%~da%~paOpen Notebook.onetoc2"
Seems 99% done, but stuck with the situation, where "if exist *.one" includes the .onetoc2 files into the "search" as well, which is unwanted. I would only like the "search" to find .one files, not .onetoc2 among them, as it is important to skip deleting the .onetoc2 file, if .one file(s) exist in that directory.
Many thanks in advance! :)