Page 1 of 3 123 LastLast
Results 1 to 15 of 42
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Batch files to delete? (WinXP)

    I use batch files to automate operations such as backups on my home computer, and there are a couple of operations I find I do manually quite often so I'd like to automate them, too - deleting anything (file or folder) called "_vti_cnf" (space-wasting files created by FrontPage) and *.met (created on ripping CDs - my own, I might add - to my hard disk). These are not necessarily in a particular folder and I therefore need to search through sub-folders to find them.

    However, it's been too long since I had to use DOS and I can't for the life of me remember how to set up something like this!

    Can anyone help, please?!

    Ta muchly!
    Beryl M


  2. #2
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch files to delete? (WinXP)

    Beryl

    rd /s /q c:_vti_cnf
    del /s c:*.met

    The DEL might need a /Q as well.

    See how these, or a variant thereof, goes.

    Here's one of mine that I made (much) earlier:

    del "c:documents and settingsca??????" /s
    del "c:documents and settings~*.tmp" /s
    del c:~ /s
    rd c:config.msi
    rd c:wutemp

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Batch files to delete? (WinXP)

    Thanks, John - the DEL line works perfectly.

    However, the RD line just says something like it couldn't find the file specified - could this be because they are often folders, which are not empty? I want to delete both folder and contents ...

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Beryl M


  4. #4
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch files to delete? (WinXP)

    Beryl

    The RD command should work -- just do RD /? in a Command Prompt window to see the syntax.
    Obvious questions: have you spelled it proper? Is it still present?

    I did the following from my C:JG directory in the Command Prompt window:
    md $$$$
    copy *.* $$$$
    Lots of files copied across.
    rd /s $$$$
    It asked whether I really wanted to delete $$$$ -- I said no.
    rd /s /q $$$$
    and it got rid of the folder/directory and all the files.

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Batch files to delete? (WinXP)

    Hmm - is there a difference between these two:

    rd /s /q _vti_cnf
    rd /s /q c:_vti_cnf

    Only the one with c: in is what you said in your first post, the other in your second? I'll try the new version and see what that does!

    Ta muchly
    Beryl M


  6. #6
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Batch files to delete? (WinXP)

    Oh - just thought - most of them are hidden! Is there a switch for that? h, perhaps?!
    Beryl M


  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Batch files to delete? (WinXP)

    And again - They are not all in the same place; the RD /? seems to indicate that the exact path has to be given - which would explain why "c:_vti_cnf" would get a message that it couldn't find the folder specified - there isn't one at that precise location.

    However, FrontPage creates a folder with this name within every folder of every web - I therefore tend to have dozens, even hundreds of them around, and every time I change/add anything in a web a new set of these <img src=/w3timages/censored.gif alt=censored border=0> folders is made for the entire web the change was made in! It is therefore pretty well impossible for me to specify every possible location for the folder ...

    <img src=/S/weep.gif border=0 alt=weep width=21 height=16>
    Beryl M


  8. #8
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch files to delete? (WinXP)

    Beryl

    OK, so it was more difficult than i thought!

    Try, in a BATch file (cut and paste, preferably!):

    <big>for /f "tokens=*" %%x in ('dir /ad/b/s c: ^| find /i "_vti_cnf" ') do echo "%%x"</big>

    When you're happy that it is echoing the correct directories, change the echo to rd /q /s and it should do what you want.
    If you need what it's doing explained, just ask.

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Batch files to delete? (WinXP)

    Ulp!! I thought I was pretty well up on DOS commands, but that ...

    Well, I can see it's a 'for' loop, that finds things called _vti_cnf in c: ... er ...
    <img src=/S/confused3.gif border=0 alt=confused3 width=45 height=45>

    Nope, I give in. What does it do?!

    Whatever it is, it works perfectly, by the way!
    Beryl M


  10. #10
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch files to delete? (WinXP)

    Beryl

    These "command extensions" came in in NT4, and now make BATch files capable of doing very large amounts of stuff. I've usually used them to do the same sort of thing on LOTS of servers or workstations. Look at FOR /?, SET /?, IF /?, and so on.

    It's quite easy to split up what's happening.

    DIR /AD/B/S C: gives a "bare list" of all the directories on the C: drive. The results are piped to
    FIND /I "_VTI_CNF" which extracts any with the _vti_cnf directory name (in any case). The
    FOR /F command takes the whole directory path as the variable %%x, and then
    ECHO es it between double quotes.

    The first two commands you can run in an ordinary command prompt window, as
    DIR /AD/B/S C:
    and then
    DIR /AD/B/S C: | FIND /I "_VTI_CNF"

    Don't worry, it's taken me about three years to become vaguely proficient in this sort of thing!

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  11. #11
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Batch files to delete? (WinXP)

    John, I had a thought about these batch files in general .. is it possible to get one to close down and restart a windows program?

    Reason I ask is that (like a lot of people, I suspect) I use Outlook for all sorts of reminder etc, and sometimes get caught out because you can't backup the PST files while it's running, so I close it down, set the backup running and forget about it - then only realise I've missed something when I restart Outlook a while later and all the reminders pop up!

    Therefore I'd like to set the batch file to close outlook, backup the PSTs and restart it, if I can ...?

    Ta muchly!
    Beryl M


  12. #12
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Batch files to delete? (WinXP)

    And another thought - can you run batch files from within a batch file? So I could set it to run my main backup routines one after the other with one click?

    (I know, I'm getting really lazy ... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>)
    Beryl M


  13. #13
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch files to delete? (WinXP)

    Beryl

    I've been asked that one recently, but the only way of doing this is to kill the Outlook.exe process, which I'd be rather reluctant to do as a matter of course since Outlook should really be closed down properly. I could detect that it was running and give you a message to get you to close it down manually? Is that good enough? Or perhaps someone can say that killing the process is fine!

    The sort of code involved in a BATch file would be:

    for /f "tokens=2" %%x in ('pslist ^| find /i "outlook"') do echo %%x

    DO Cut and Paste that! It will echo the PID of the OUTLOOK.EXE process, so if/when it's working you'd replace the echo with pskill. Test it and see if it works, since I don't run Outlook no more...

    All the PsTools come from SysInternals.

    You can CALL a BATch file from within a BATch file, as in

    CALL SHOWCATS.BAT Jinks

    (and you can leave the .BAT off also). Control returns to the next statement in the calling batch file after SHOWCATS has completed.

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  14. #14
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Batch files to delete? (WinXP)

    Unfortunately, not only can I guarantee no-one will be able to say (accurately) that using KILL is okay, I can tell you now it isn't!

    I'd been having terrible problems with Outlook continually complaining that there were problems with the data files then every so often dying completely and having to be repaired. I tracked it down eventually to the fact that having shut down Outlook, it was taking a while to close properly and the batch file was tripping up ("can't access *.pst because another operation has locked a part of that file"), so I'd check the tasklist, find outlook.exe still running and kill it, thinking it was stuck. When I stopped doing that and let it have a minute or two more to close down each time, everything was fine again and has remained so.

    Nor do I need reminding it's running - it always is, except when I switch it off to run the backup! If anything I need a reminder to reopen it when the backup has finished ... that's a point - can I get it to say "all done, reopen Outlook now"?

    Or even (which is what I really need) - can I get the batch file to start Outlook again when it's finished? I can close Outlook down myself before running the batch file, but it's the fact that I forget to start it again that causes the problems!

    Re the CALL statement, I don't understand the syntax? CALL SHOWCAT[.bat] is fine - but what are you using the 'Jinks' bit to indicate?

    ( <img src=/S/catty.gif border=0 alt=catty width=19 height=18>By the way, we went to a show on Sunday and he got his first CAC championship certificate, the gaining of three of which will make him a Champion! Next show's not until the spring, though, so we have to wait a while now ... <img src=/S/catty.gif border=0 alt=catty width=19 height=18>)
    Beryl M


  15. #15
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch files to delete? (WinXP)

    > can I get it to say "all done, reopen Outlook now"?

    Of course you can, just stick whatever you find in the Outlook shortcut (I'm guessing here):
    <some path or other>outlook <maybe some parameters>
    as the final statement of your Backup BATch file.

    > Re the CALL statement, I don't understand the syntax? CALL SHOWCAT[.bat] is fine - but what are you using the 'Jinks' bit to indicate?

    There Jinks is just a parameter being passed to the BATch file, which may not be needed for a backup BATch file. (Of course you could have been showing Jaffa or Jessie!). Soon Jinks will be even more famous than you!!

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •