Is it possible to delete all subfolders in a specific folder without hard-coding them or deleting anything else?

Viewed 105

I was wondering if it was possible to delete all of the subfolders in a folder without deleting other files with AutoHotKey. For example, if I have a folder named "ASDF", and I have 3 subfolders and a required essay in it, is there a way to delete ONLY the folders, without naming them in the code (say one of the folders was named "FDSA", I want to write the script in a way such that the name is not included in the code)? I have tried using the "FileRemoveDir" Function but it does not seem to work. Here is the code I have so far:

FileSetAttrib, -RASH, %A_Desktop%\FileName\*
FileDelete, %A_Desktop%\FileName\*
FileRemoveDir, %A_Desktop%\FileName\*, 1


FileSetAttrib, -RASH, %A_MyDocuments%
FileDelete, %A_MyDocuments%\*
FileRemoveDir, %A_MyDocuments%\*, 1
return

If it helps at all, I run on a windows computer. Answers will be appreciated, thak you!

1 Answers

yes you loop over the files check if they are folders if so delete them

Loop, %a_scriptdir%\asdf\*, 1 
{
If (FileExist(A_LoopFileFullPath) = "D") {
    FileRemoveDir, %A_LoopFileFullPath%
}
}
Related