1

I have been tinkering with some batch files to clean up some of my folders and I am stuck. What I am trying to do is check the directory Installers for any files or folders and then either :goto empty or :goto notempty . I have spent ages searching for a solution but everything that I have found is to either check if only files exist in a directory or check if a specified folder exists in a directory.

EDIT: This is what I have so far.

@echo off
echo Beginning File Cleanup

echo Installers Start
"C:\Program Files\WinRAR\rar.exe" a -r -df "Installers.rar" Installers
echo Installers Done

echo old Start
"C:\Program Files\WinRAR\rar.exe" a -r -df "old.rar" old
echo old Done

mkdir Installers
mkdir old

pause

The code above works but I only want it to run the rar.exe bit if the folder is empty hence to :goto requirement Thanks

  • Does this answer your question? [Check if any type of files exist in a directory using BATCH script](https://stackoverflow.com/questions/10813943/check-if-any-type-of-files-exist-in-a-directory-using-batch-script) – Ste Jan 26 '20 at 13:00

1 Answers1

0

I must be missing something, but I didn't saw how does you current code relate to what you asked...

You can do what you want with the following line

dir /b "path/to/Installers" | findstr "^" >nul && (echo Folder not empty) || (echo Folder is empty)

Just see what happens at the echo parts and replace for the command you want.

Cheers.

Daniel Luz
  • 134
  • 1
  • 6