Creating a .bat file?

  • Thread starter Thread starter Kate
  • Start date Start date
Kate said:
The command prompt worked correctly, so I must be doing something
wrong creating the .bat. In Notepad, I wrote
del \F:\Documents and Settings\(user name)\Local Settings\Temp\p*.tmp
del \F:\Documents and Settings\(user name)\Local Settings\Temp\t*.tmp

Don't use the first forward slash in the path and use the quotation
marks, try it *exactly* like this:

del "F:\Documents and Settings\(user name)\Local Settings\Temp\p*.tmp"
del "F:\Documents and Settings\(user name)\Local Settings\Temp\t*.tmp"

John
 
John John - MVP said:
Don't use the first forward slash in the path and use the quotation
marks, try it *exactly* like this:

del "F:\Documents and Settings\(user name)\Local
Settings\Temp\p*.tmp"
del "F:\Documents and Settings\(user name)\Local
Settings\Temp\t*.tmp"

John

YeeHa! It worked! Thank you very much indeed, John.

Kate
 
Kate said:
YeeHa! It worked! Thank you very much indeed, John.

You're welcome. Just a reminder that you have to be extremely careful
when using wildcards to delete files! It might not matter too much with
temp files but with any other files this can be like dynamite!

John
 
John John - MVP said:
You're welcome. Just a reminder that you have to be extremely
careful when using wildcards to delete files! It might not matter
too much with temp files but with any other files this can be like
dynamite!

John

Yes, indeed! I do not know if you were around in the days of Win
98SE, but there was one charming poster to the ms help and support NG
who used to reply to pleas for help with the instruction to use the
deltree y command, saying that all the OP`s problems would be solved
if they ran it. Fortunately, I never got caught, but all the warnings
which were posted at the time have made me cautious about any "del"
command. Thank you for the warning, though.

Kate
 
Leonard said:
While this thread has been going on I have cleaned out my temp folders
142 times.
---

Surely you jest, Leonard! The thread's just 24 hours old.

Kate's right. You could use a batch file...

Bill
 
I`m glad you posted, Bill, because it has given me a chance to ask
for more help, please?

The same program that I have been grumbling about puts a "Hidden"
folder in my Documents and Settings\(user)\Cookies folder. Because I
have "Show Hidden Files & Folders" checked, I am able to see it, but
cannot delete it using the line

del "F:\Documents and Settings\(user)\Cookies\(folder name)"

The contents of the folder are deleted, but not the folder.
What sort of wording should I use to delete the folder itself and its
contents, please?

Many thanks
Kate
 
Au contraire, Bill. Since it takes less than 3 seconds for me to click
twice on CCleaner, I could have cleared my temp files thousands of times
in a 24-hour period.

And as you'll soon find out, this thread is still not over. ;-)
 
Use the RD command.

rd /s /q "F:\Documents and Settings\(user)\Cookies\(folder name)"

At the Command Prompt do RD /? for information on the switches.

John
 
Adding to what John here said, "rd" stands for remove directory, Kate.
Another good and powerful command is "deltree" - just be very careful if
and when you use it. Deltree deletes everything in the directory, even if
its not empty, which I don't think "rd" will do. You can look it up on the
net.
 
Bill said:
Deltree deletes everything in the directory, even if
its not empty, which I don't think "rd" will do.

That is what the /s switch is for. Do rd /?

John
 
As you will see in my reply to John, "rd" removed the folder, so I
assume its contents were also deleted. They are not in the Cookies
folder, anyway.
Re the deltree command, I really would prefer to avoid using it
because of all the dread warnings years ago about deltree y (see my
earlier post about Win98).

Kate
 
Thank you very much once again, John. Works a treat.
Somebody told me that the % sign can be used instead of writing out
the whole path, but, as a complete DOS novice, I think I would rather
see the full path so that I can easily see if I have made any
mistakes.

Kate
 
You're welcome. By the % they meant that you can use variables in the
batch file. For more information open a command prompt and issue the
SET command and you will see some of the variables.

While at the command prompt you can experiment with the CD command and
see the results:

cd \

cd %userprofile%

cd %systemroot%

cd %appdata%

cd %windir%

Someone writing a batch file for use on other people's computer wouldn't
know their user names or profile folder path so they would use the
variable to make sure that the command runs properly:

echo %userprofile%\cookies

The cd and echo commands work even if there are spaces in the path but
most other commands still need to use "quotation marks" to ensure that
the command runs properly, for example the MD (Make Directory) command
without quotation marks:

md %userprofile\TestFolder

will have unexpected results, there will be no TestFolder in the
expected user folder at C:\Documents and Settings but there will be
several new folders in the root of the c: drive, to run properly the
command needs quotation marks:

md "%userprofile\TestFolder"

John
 
SC said:
Deltree is not available in XP Home, unless you got it from somewhere else?

It doesn't seem to be available in XP Pro either, at least on my
machine. No matter, rd /s works just fine, if needed.

Bill
 
It's on my DOS flash disk, where I had been using it. Now that you mention
it, I guess it would be useless on XP with NTFS. My Bad.
 
Thank you for the explanations, John.
I see that one of your examples uses "echo". I used the echo /?
command to find out more, but all that was mentioned was echo on and
echo off, not what it actually does. Another user of the program that
creates all the unwanted temp files has written a batch file but for
Win 4NT, and I gather that the wording will be different to a batch
file for Win XP. He has written his .bat so that, 30 seconds after he
closes the program, the rest of the batch file will run automatically
and clean up the temp files. The entries he has written are :

@echo off
"C:\Program Files\DxO Labs\DxO Optics Pro v6\DxOOpticsPro6.exe"
delay 30

followed by the del instructions. Will these three lines as written
work for the batch file you have helped me with, please? I ran a
@ /? command but the details said it was not recognised, so I am
reluctant to experiment and add these lines to my .bat without advice
in case something goes very wrong.

Thanks
Kate
 
Back
Top