0

I have a file structure of images that is fairly flat although quite large (only goes 3-4 levels deep). In this structure I want to delete all folders that end with '.files' (no quotes).

Note that the files I want to delete are hidden.

I saw a relevant question (linked below) that suggested the following batch file (except using '_svn')

Command line tool to delete folder with a specified name recursively in Windows?

for /d /r . %d in (_svn) do @if exist "%d" rd /s/q "%d"

but it didnt work quite right for me. I got the following error when running at the directory I want to start: d" rd /s/q "d" was unexpected at this time.

So to be clear, I'm looking for a command that I can put into a batch file which I can cd to my desired directory, run the command, and delete directories beneath the current directory that end in '.files'

Any suggestions?

Community
  • 1
  • 1
Anthony Elliott
  • 2,941
  • 5
  • 29
  • 42

1 Answers1

2
for /f %a in ('dir C:\yourdir\*.files /b /s /a:hd') do rd /s /q "%a"

or if running it from a batch file use 2 %'s

for /f %%a in ('dir C:\yourdir\*.files /b /s /a:hd') do rd /s /q "%%a"
Bali C
  • 30,582
  • 35
  • 123
  • 152
  • Oh, just realized that the files I want to delete are all hidden (didn't realize that meant they weren't normally accessible from the command line). How can I change this to work with hidden files? I'll edit the original question to show that. Thanks for the help, btw. – Anthony Elliott Dec 13 '12 at 15:53