Click here to Skip to main content
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 4:53am
Edited 26-Sep-12 5: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 OriginalGriff 406
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 205
3 /\jmot 175
4 Shweta N Mishra 161
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 26 Sep 2012
Copyright © CodeProject, 1999-2014
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