I was wanting to know if there is a way to find a folder or file with a specified name delete all its conents without knowing its full path or directory structure,,,
Can this be accomplished via a script or command line or powershell
In this example I am looking for any folder named temp.... These temp folders that are in question are in unknown locations.... very deeply nested/rooted. all over the place...
I was messing with the command dir, and findstr. and came up with some results, but how do you combine this with the delete or do something command.
dir /b /s /ad | findstr /i "\<Temp\>" |findstr /v " "\<exlude\>"
Also the findstr /I "\<Temp\>" does indeed find all the temp directories, however it also list all the child items and folder in the temp directory. (which I dont necessary want) is there a command to only print or list just the root folder with \\.\\.\\.\\.\\. Temp\
... without knowing where the orginal temp directory is....or how far down it is nested...
AKA: you don't know its abosulte path... just its name...
Also messing with the variable dir /b /s /ad | findstr "\<Temp"
Includes both the temporary Internet and the temp directory which is good. but it also list anything that starts with temp, example template.... in this example I would use the exlude template... But I also came across some other weird names that was listed in this group.. so perhaps just the constanit (temp) or (temporary) and then delete its contents
I was trying to use the findstr /v to exlude any of the results I didn't want shown, but these excluded results vary and are named various things. also can the dir /b /s /ad |findstr be used with a command to also delete all the files in the location and directories inside the temp...Again this is without knowing its true location... just the name of the directory...and its somewhere on the drive... may be 1000 folders deep or 10 deep.
Can all of these be accomplished via a powershell, vbs (vbscript) or cmd.exe (batch) .bat file?