Solved Wildcard needed in batch

November 5, 2015 at 03:47:02
Specs: Windows 64

i need help with deleting some folders in the Firefox History.
The script works fine so far but deletes too much.

IF EXIST "C:\Users\" (
for /D %%x in ("C:\Users\*") do (
del /f /s /q "%%x\AppData\Local\Mozilla\Firefox\Profiles\*"
--> It deletes everything in \Profiles -> Users loose their Settings like starting-Page.

What it should do is something like:
del /f /s /q "%%x\AppData\Local\Mozilla\Firefox\Profiles\*\ONLY the Folders\

-> How to set a working wildcard on the "*" position?
Thanks for help!

See More: Wildcard needed in batch

Report •

November 5, 2015 at 04:47:29
✔ Best Answer
Try using RMDIR instead of DEL

In cmd:

rmdir /?

Instead of using wildcards, you can use variables in a for loop:

...\Profiles\*\ONLY the Folders\
I assume you want to delete all folders in every directory in Profiles.

Just to point you in the right direction.

@Echo off
:: Not tested
cd "%profilesPathToFirefox%"
for /f "tokens=*" %%A in ('dir /B /A:D "%CD%"') do (
       cd %%A
       for /f "tokens=*" %%B in ('dir /B /A:D "%%A"') do (
              :: rmdir /s /q %%B

Change %profilesPathToFirefox% to the actual path.
Remove the "::" before the RMDIR command to enable deletion.
Hope this helps.

Marking answers that solve, or help helps you solve a problem as "Best Answer" also helps other people solve similiar ones in the future.

message edited by RainBawZ

Report •
Related Solutions

Ask Question