Question : Deleted nested folders and files with powershell

I need a script it can be vb or powershell or even a batch file that will delete  all the contents of several sub folders from a directory but leave the first level sub folder intact. For example:

D:\Books\100\101\test.txt
D:\Books\200\202\test.txt
D:\Books\300\301\test.txt
D:\Books\400\test.txt

After the script runs I want to only have this left:
D:\Books\100
D:\Books\200
D:\Books\300
D:\Books\400

I am stuck at this point using powershell:

Get-ChildItem -Path D:\Books -Recurse -force |
Remove-Item –Force

Answer : Deleted nested folders and files with powershell

Here is the correct script.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTopFolder = objFSO.GetFolder("C:\Books")

For Each objSubFolder In objTopFolder.SubFolders
	For Each objFile In objSubFolder.Files
		WScript.Echo "Delete " & objFile
		objFSO.DeleteFile objFile
	Next
	For Each objSubSubFolder In objSubFolder.SubFolders
		WScript.Echo "Delete " & objSubSubFolder
		objFSO.DeleteFolder objSubSubFolder
	Next
Next
Random Solutions  
 
programming4us programming4us