Re: question about BAT file creation

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I have Temp folders on more than one drive, and often they get full
with files created by particular software I use; I just want to be
able to check their contents, and if neccessary remove the files
therein. While I do have some "cleaner" programs which remove temp
files, they don't always do the trick.

I'm trying to create a BAT file which will change to each Temp folder
location, and list its contents. However, no matter how I type it, it
always just shows C: drive and nothing else. This is how I type it in
Notepad:

cd c:

dir /s /b *Temp

pause

cd g:

dir /s /b *Temp

pause

cd v:

dir /s /b *Temp

pause

What I don't understand is, these commands work fine if I type them
in the Command Processor window in sequence. I just can't seem to get
them to work in sequence as a BAT file.

Once you have your head around them, they will <g>.

Any idea what I'm doing
wrong? I'm clearly missing an extra command/s to get the BAT to work.
I want the BAT to work no matter where it is located on my PC, too;

Then it simply needs to reside somewhere in the "Path", most logically
probably your Program Files directory/folder. Directory = Folder; same
thing.

for some reason it only lists C: no matter where I run it from.

That's because of your "CD C:" line. It has to be simply " C: " CD
only works for "Change Directory"; drives are not directories(folders).

Tim


"CD C:" does not work as you expect from the command prompt. It does
something, but not what you expect. Your following DIR will display
whatever drive you were on when you executed the CD, NOT the one on C:.
Look closer and you'll see it. Or just hit Return and you'll see you're
still on the original drive, not C.

The correct command is simply "drive:" or, C: for instance. THEN,
regardless of where you were, you will go to the drive C: root
directory.


Assuming the batch file also does the deletions, which you have not
indicated in your code above:

In addition to the other posts, I'd just like to add something I didn't
notice mentioned and directly respond to a couple points you made:
IF a particular temp file happens to be in use you can not delete
it. That's going to cause the batch file to present an error message at
delete time. You can often avoid that if you make running the batch
file the very first thing you do after a boot. Or, employ the
appropriate error catching techniques.

In order for a .bat to work "no matter where it's located on your PC",
two things are necessary:
The .bat file either:
-- MUST reside in the folder you execute it from, OR
-- The .bat file MUST be in the path. This is the best answer to your
problem rather than having several batch files spread all over the
place. A logical place to put it for produtcion use would be your
Program Files folder. Then it'll run no matter where you execute it
from. Because it's in the "path".

IF the batch file resides anywhere that is NOT in the path, then you
will also have to use fully qualified paths within the file; e.g.
c:\windows\temp...\... , which I don't think is what you want to do.

HTH

Twayne


.



Relevant Pages

  • Re: Help with deletion of files in XP at bootup
    ... erase Cookies, Temp, History, and Temp. ... autoxec.bat *is* a batch file. ... Windows 98, and doing anything similar remains a bad thing to do in Windows ...
    (microsoft.public.windowsxp.general)
  • Re: Cant schedule a batch file to run in the XP Pro Scheduler
    ... Also look in Explorer and right-click the BAT file itself and check that all ... > a shortcut on the desktop or from the command window directly. ... > does NOT run fine is when I try to call the backup.bat batch file ... Why doesn't the XP task scheduler handle batch files? ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Gateway Laptop doesnt like the cold
    ... Temperature was 9 degrees F. I stopped at the Y for ... reach room temp again, after it's been outside in subzero temps. ... This is what is inside one of those solid state drives. ... CCFL fluorescent tube (they use around 1000 volts AC to ...
    (alt.comp.hardware.pc-homebuilt)
  • Re: laptop hd temps running hot
    ... operating temp is good to 140 F so I'm not worried yet and some hd ... Laptop is a duo2core processor running xp media ctr.. ... looking for seagate specs I saw a toshiba spec??? ... do you think the laptop made the drives ...
    (alt.sys.pc-clone.dell)
  • Re: External hard drive not showing on My Computer
    ... a .bat file then run it, the batch file will automatically open your Device Manager where you can then select the "Show hidden devices" from the "View" Menu. ... The light shaded devices are phantom devices. ... Review Disk Drives, USB and Storage Volumes. ... can use this USB powered Drive with the laptop? ...
    (microsoft.public.windowsxp.general)