Certainly! Below is a batch script that will do as you requested. To use this script, you need to:
- Copy the code into a text editor like Notepad.
- Save the file with a
.bat extension, for example, FindNonAudioFolders.bat.
- Place the
.bat file in the root directory you want to scan.
- Double-click the
.bat file to run it.
Here's the script:
@echo off
setlocal enabledelayedexpansion
:: Define the output file name
set "outputFile=%~dp0NonAudioFoldersList.txt"
:: Clear the output file if it already exists
if exist "%outputFile%" del "%outputFile%"
:: Loop through all subdirectories
for /d /r %%D in (*) do (
set "containsAudio=false"
set "containsOther=false"
:: Loop through all files in the subdirectory
for %%F in ("%%D\*") do (
if "%%~xF"==".mp3" set "containsAudio=true"
if "%%~xF"==".m4a" set "containsAudio=true"
if "%%~xF"==".flac" set "containsAudio=true"
if "%%~xF"==".opus" set "containsAudio=true"
if "%%~xF"==".wav" set "containsAudio=true"
if not "!containsAudio!"=="true" set "containsOther=true"
)
:: If the folder contains no audio files and it contains other files, write it to the output file
if "!containsAudio!"=="false" if "!containsOther!"=="true" echo %%D>>"%outputFile%"
)
:: Check if the output file is created and has content
if exist "%outputFile%" (
if %~z0 == 0 (
echo No non-audio folders found.>&2
del "%outputFile%"
) else (
echo Non-audio folders have been listed in "%outputFile%".
)
) else (
echo No non-audio folders found.>&2
)
pause
endlocal
This script will create a text file named NonAudioFoldersList.txt in the same directory as the script itself, listing all folders that do not contain audio files but contain other files. Empty directories will be ignored because they don't contain other files.
Please note that this script checks for the specific audio file extensions you provided. If you have other audio formats, you would need to add the corresponding extensions to the script.
To run the script, simply double-click the .bat file you created. A command prompt window will open, and once the script completes, you'll either have the list in the text file, or it will inform you that no such folders were found.