Hello Guest, Welcome to Apnea Board !
As a guest, you are limited to certain areas of the board and there are some features you can't use.
To post a message, you must create a free account using a valid email address.

or Create an Account


New Posts   Today's Posts

[How to] Help with a Batch File Command
#1
Question 
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)

Admin Note:
JustMongo passed away in August 2017
Click HERE to read his Memorial Thread

~ Rest in Peace ~
Post Reply Post Reply
#2
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
tree.

/Q Quiet mode, do not ask if ok to remove a directory tree with /S
Post Reply Post Reply
#3
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
______________________
Useful Links -or- When All Else Fails:
Posting SleepyHead Charts in 5 Easy Steps
Robysue's Beginner's Guide to Sleepyhead
Apnea Helpful Tips
Post Reply Post Reply


#4
(02-13-2015, 01:13 PM)sgearhart Wrote: 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

Hence the name DUMMY FILE. I have it in a test BAT file and am actually targeting a dummy folder that I put so junk folders and files in.

Admin Note:
JustMongo passed away in August 2017
Click HERE to read his Memorial Thread

~ Rest in Peace ~
Post Reply Post Reply
#5
OK, Basically the only thing that I added to your code was the addition of "\*" at the end of your command.
______________________
Useful Links -or- When All Else Fails:
Posting SleepyHead Charts in 5 Easy Steps
Robysue's Beginner's Guide to Sleepyhead
Apnea Helpful Tips
Post Reply Post Reply
#6
It appears that the RMDIR command should be used. But, it will get stuck on hidden files.
The DELTREE command is obsolete.
I may have to use both ERASE with switches, then RMDIR.
The /F switch on ERASE deletes hidden files.

Admin Note:
JustMongo passed away in August 2017
Click HERE to read his Memorial Thread

~ Rest in Peace ~
Post Reply Post Reply


#7
yummmmm batch files.... I gave them up and went bash Smile
هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه
Tongue Suck Technique for prevention of mouth breathing:
  • Place your tongue behind your front teeth on the roof of your mouth
  • let your tongue fill the space between the upper molars
  • gently suck to form a light vacuum
Practising during the day can help you to keep it at night

هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه هههههه
Post Reply Post Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  File Hash check program justMongo 3 547 10-14-2016, 01:32 AM
Last Post: srlevine1
  what's wrong with this fragment of windows batch code? justMongo 18 2,290 09-16-2015, 10:46 AM
Last Post: AlanE

Forum Jump:

New Posts   Today's Posts




About Apnea Board

Apnea Board is an educational web site designed to empower Sleep Apnea patients.

For any more information, please use our contact form.