I am new to the batch scripting. I would like to delete some folders and files using batch scripting. For example I have 10 folders under this directory "C:\test", in each folder there are files and folders available like "D:\test\check*". I have to navigate to "D:\test" and select a folder "D:\test\check", and navigate to the subfolders like "D:\test\check\folder1" and delete the files and folders there.
My script should come back to "D:\test", and select the appropriate folder, and navigate to destination folder to delete the text files and folders available. I am thinking if there is a possibility to write bat file which navigate back and forth to delete the files and folders. Currently I am deleting them by providing the destination path for file and folders, but I am not sure if that is the feasible solution or not. If use this method then I have to provide a explicit path to delete.
This is what I am using right now.
for /d %%p in ("D:\test\*") do (
echo %%p
del /s /q "D:\test\check\folder1\folder2\*.*"
for /d %%p in ("D:\test\check\folder1\folder2\*.*") do rmdir "%%p" /s /q
)
Thanks in advance.