Click here to Skip to main content
11,705,098 members (48,108 online)
Rate this: bad
good
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"
) 
ELSE 
(
echo "Not exists"
pause
)
Thanking you in advance
Posted 26-Sep-12 3:53am
Edited 26-Sep-12 4:41am
v3
Rate this: bad
good
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:
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
  Permalink  
v2
Rate this: bad
good
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
pause
  Permalink  
v3

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 595
1 OriginalGriff 289
2 Andy Lanng 175
3 CPallini 162
4 ppolymorphe 126
0 OriginalGriff 8,958
1 Sergey Alexandrovich Kryukov 8,276
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | 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