02-13-2015, 12:22 PM
I'm working on a batch file for my WIN 7 machines.
I am having trouble with one line. It worked before I tried to add the IF EXIST test. Now, it seems to be ignoring the switches; and deletes only the files, not the folder tree.
What is wrong with this line?
IF EXIST "C:\Users\%USERNAME%\Documents\DUMMY FILE" (ERASE "C:\Users\%USERNAME%\Documents\DUMMY FILE" /F /S /Q)
INFORMATION ON APNEA BOARD FORUMS OR ON APNEABOARD.COM SHOULD NOT BE CONSIDERED AS MEDICAL ADVICE. ALWAYS SEEK THE ADVICE OF A PHYSICIAN BEFORE SEEKING TREATMENT FOR MEDICAL CONDITIONS, INCLUDING SLEEP APNEA. INFORMATION POSTED ON THE APNEA BOARD WEB SITE AND FORUMS ARE PERSONAL OPINION ONLY AND NOT NECESSARILY A STATEMENT OF FACT.
RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path
/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
/Q Quiet mode, do not ask if ok to remove a directory tree with /S
Have you tried:
DEL /F /S /Q /A "C:\Users\%USERNAME%\Documents\DUMMY FILE\*"
I think I'd play with this command with a dummy directory/file setup. Based off of what you listed, it is very possible to accidentally delete your My Documents Directory