If or conditions and hidden system files

October 4, 2009 at 12:44:28
Specs: Windows Vista
I'm writing a simple batch script to clean out
my music library. My aim is to remove
everything but the music files themselves. So
far it kind of works in that it deleted random
text files and such in my music folder, but
there are unwanted album art files that are
considered hidden system files, so my script
ignores them. However, that also means that
folders with only those hidden files will not be
deleted because they are technically not
empty.

My other question is, can I have if/or
conditions in batch files such as (if
string==string1 || string==string2)?

Here's the code I currently have...

@echo off
setLocal EnableDelayedExpansion

FOR /R . %%f IN (*.*) DO (
	if not "%%~dpf" equ "%CD%\" (
		if "%%~xf"==".jpg" (
			call :Delete %%f
		) Else (
			if /i not "%%~xf"==".m4a" (
				if /i not 
"%%~xf"==".mp3" (
					if /i not 
"%%~xf"==".wma" (
						if /i not 
"%%~xf"==".m3u" (
							if /i not 
"%%~xf"==".m4p" (
								
call :DeleteP %%f
							) else 
call :Keep %%~nxf
						) else call 
:Keep %%~nxf
					) else call :Keep 
%%~nxf
				) else call :Keep 
%%~nxf
			) else call :Keep %%~nxf
		)
	)
)

for /f "tokens=* delims= " %%a in ('dir/b/s/ad') 
do (
	dir/b/a-d "%%a" > nul 2> nul
	if errorlevel 1 echo %%a is empty
)

goto :Done

:Keep %*
echo Keep %*
exit /b

:Delete %*
echo Delete %*
del "%*"
exit /b

:DeleteP %*
del /p "%*"
exit /b

:Done
echo.
echo Done

Thanks for any help/advice!


See More: If or conditions and hidden system files

Report •


#1
October 4, 2009 at 16:08:02
but
there are unwanted album art files that are
considered hidden system files, so my script
ignores them.

attrib -s -r -h * /s

My other question is, can I have if/or
conditions in batch files such as (if
string==string1 || string==string2)?

Nope. You can have but one test per IF statement. If you want a second, you must use a second IF statement.


Report •
Related Solutions


Ask Question