how can I get a Batch File to Delete a folder if it doesnt contain a specific file

خرید بک لینک

Hi I'm new here and was hoping someone can help me with a problem I have. Over the years I have acquired a number of ebooks (several thousand). So I have decided to only keep my mobi and Epub books. However the problem I have is that some of the ebook folder have now got only metadata files .opf and images .jpg. I cannot do a general search for the .epub file extension. What I want to do is have a batch file that will go through my folder and look to see if a epub file is in the folder and if not to delete the folder.

I have tried the following script on a test but the problem with this is that it looks at 1st level folder first and if that has only sub folders within it it will delete the folder and any subsequent folders

Can someone help by either giving me pointers as to how I can the file to look from the bottom up. Another way maybe to remove all folders that contain an epub to another file and anything left delete

the script below is what I am using

echo off
setlocal enableDelayedExpansion
for /f "tokens=* delims=" %%i in ('dir /a:d /b /s x:1ebooks1test') do (
  set _dir=%%i
  if exist !_dir!*.epub (
    echo !_dir! folder is ok
    ) else (
    echo rd !_dir! get rid of folder
    )
  )
exit /b

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 155 تاريخ: يکشنبه 19 ارديبهشت 1395 ساعت: 6:33

صفحه بندی