问题描述:

I have a folder named Scripts in current directory Say C:\QTP\Script\. I am not sure the folders names and count in that scripts folder. Inside each unknown folder name i have Objective Evidences folder. I want a code that deletes all the files and folders in unknown folders but not objective evidences folder.

EG:

Scripts\Folder1\Objective Evidences (this folder1 contains many files too)

Scripts\Folder2\Objective Evidences (This folder2 also contains many files)

I am not sure how many folders are present in scripts folder and wat are their names.

I should get the list of folder names present in Scripts folder and delete all files and folder present in it except Objective Evidences folder.

Please let me know the batch code for the same.

网友答案:
for /f "tokens=*" %%G in ('dir /b /s /a:d "C:\QTP\Script\*"') do (
   echo %%~fG | FIND "Objective Evidences" || rd /s /q "%%G"
)

Try this...Or this

pushd "C:\QTP\Script\"
for /D /R  %%a in (*) do echo "%%~fa" | find "Objective Evidences" || rd /s /q "%%a"
popd
相关阅读:
Top