Folder Deletion

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MrBlister
Posts: 1
Joined: 05 Jun 2025 03:26

Folder Deletion

#1 Post by MrBlister » 05 Jun 2025 03:32

I have a .bat that runs at Startup. I want to add an extra process that deletes folders in a specific directory. The target folders will have been renamed with something like ".orph" appended at the end.
I have this for starters:
for /d "delims=" %%p in ("C:\Users\) do rmdir "%%p" /s /q
but I don't know how to specify the .orph identifier.
Help greatly appreciated, thank you.

aGerman
Expert
Posts: 4705
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Folder Deletion

#2 Post by aGerman » 05 Jun 2025 09:35

It's not quite clear to me what you're trying to do. However, you could try something like that:

Code: Select all

@echo off
for /d /r "C:\Users\user\somewhere" %%p in ("*.orph") do ECHO rmdir "%%p" /s /q
PAUSE
Update the path after the /r option accordingly and run it. The script doesn't do any harm yet, it only displays the commands that would be executed. If you think that the right folders are found, remove the ECHO command and run the script again to actually delete the folders.

Steffen

Post Reply