Hey i want to delete all files inside a folder except for few files, now these files i want to keep are normal folders & some of them are just blank files.
my files that i want to be kept
heres my current code, it keeps 1 folder only but i want to keep all 3 of the folders + my 2 blank files.
pushd "C:\Folder2" || exit /B 1
for /D %%D in ("*") do (
if /I not "%%~nxD"=="Important Folder1" rd /S /Q "%%~D"
)
for %%F in ("*") do (
del "%%~F"
)
popd
[Edit /] (from comment section)
I tried, like this:
pushd "%LOCALAPPDATA%\Google\ChromeVoter\User Data\Default\" || exit /B 1
for /D %%D in ("*") do (
if /I not "%%~nxD"=="Important Folder1" rd /S /Q "%%~D"
if /I not "%%~nxD"=="Important Folder2" rd /S /Q "%%~D"
if /I not "%%~nxD"=="Important Folder3" rd /S /Q "%%~D"
)
for %%F in ("*") do (
del "%%~F"
)
popd
It didn't work.