Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All,
I want to check if folder exits or not using batch file, if exits i want to delete that folder else do nothing.

Path of the folder is : %userprofile%\AppData\LocalLow\Dictionary

Condition is i need to do it by batch file.
Need to delete folder for all the existing users can anybody help me in solving this.
I tried the below code but not working
SET  src_dir="%userprofile%\AppData\LocalLow\Dictionary"

IF EXIST %src_dir%\NUL
(

rmdir /s /q "%userprofile%\AppData\LocalLow\Dictionary"
) 
ELSE 
(
echo "Not exists"
pause
)

Thanking you in advance
Posted
Updated 26-Sep-12 4:41am
v3

The pause isn’t really necessary
The whole line of code should be on a single line in the batch file except for the "pause" that should be on the second line.

VB
for /d %%a in ("%systemdrive%\Users\*.*") do if exist %%a\AppData\LocalLow\Dictionary rmdir /s /q %%a\AppData\LocalLow\Dictionary
pause
 
Share this answer
 
v3
The simplest suggestion is: with just deleting you cannot go wrong. If the directory does not exist, nothing will change.

If you still need a check, this old Microsoft support article explains the matter, as well as many other sources:
http://support.microsoft.com/kb/65994[^].

[EDIT]

You can get full description of all batch command and syntax on your system, if you auto-generate help using this wonderful batch script by Rob van der Woude improved by Johan Parlevliet:
http://www.robvanderwoude.com/allhelp.php[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900