Click here to Skip to main content
11,411,840 members (53,979 online)
Rate this: bad
Please Sign up or sign in to vote.
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"
echo "Not exists"
Thanking you in advance
Posted 26-Sep-12 4:53am
Edited 26-Sep-12 5:41am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:[^].


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:[^].

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.

for /d %%a in ("%systemdrive%\Users\*.*") do if exist %%a\AppData\LocalLow\Dictionary rmdir /s /q %%a\AppData\LocalLow\Dictionary

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

  Print Answers RSS
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 200
2 ProgramFOX 130
3 Sascha Lefévre 120
4 Dave Kreskowiak 90
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 7,128
2 Maciej Los 3,440
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web01 | 2.8.150414.5 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100