Batch File

Discussion in 'Techie Discussion' started by ]SK[, Jan 22, 2004.

  1. ]SK[

    ]SK[ One of Freddy's beloved

    Anyone think this is possible?

    I want to delete all *.ztmp files. Can I make the batch search though subfolders and delete any .ztmp files it finds?

    Last resort would be to add each subfolder, which will take a long time :(
  2. sibanac

    sibanac Fledgling Freddie

    on unix :

    find / -name \*.ztmp  -ok rm {} \; 
    on windows i havent got any idee except using the search and then deleting all the results manualy
  3. babs

    babs Can't get enough of FH

    Del x:\*.ztmp /s (/p if you want a y/n prompt), obviously replacing x for whichever drive you want.
  4. ]SK[

    ]SK[ One of Freddy's beloved

    I love you
  5. ]SK[

    ]SK[ One of Freddy's beloved

    Is there a way to output the deleted info into a txt file as well as onscreen?

    The batch is this atm...

    Echo *  This little batch file will clean out	*
    Echo *  temporary ztmp files created from clients	*
    Echo *  downloading maps off the server.		*
    Echo *  If you do not wish to continue close		*
    Echo *  this window.					*
    Echo *  This script is written thinking your HLDS	*
    Echo *  installation is installed in c:\hlserver		*
    Echo -
    cd c:\
    cd hlserver
    Echo Deleting ztmp files...
    Echo -
    del *.ztmp /s
    Echo -
    Echo OK All clean!
  6. Shovel

    Shovel Can't get enough of FH

    Yes :)

    Add the following to the del command:
    del *.ztmp /s > X:\path\to\output.log
    Just make sure that the script is flawless first, since any prompts will also get redirected into the log file.

    If you want the same log file to have the data appended (rather than a new log file every time - you could for instance make a dynamic name using DATE or something) then replace with something like this:
    echo >> output.log
    date /t >> output.log
    del *.ztmp /s >> output.log
    Note the ">>" rather than ">". The ">>" means "Append" rather than writing a new file.

    I hope that works for you :)
  7. ]SK[

    ]SK[ One of Freddy's beloved

    Ah I did do it right but I was looking in the wrong place :eek:

    Is there a way to make the log appear in the same place as where the batch is?
  8. babs

    babs Can't get enough of FH

    Just specify the path before the log file name.

    e.g. if .bat is in c:\files\temp\ then del *.ztmp /s >> c:\files\temp\output.log
  9. ]SK[

    ]SK[ One of Freddy's beloved

    Yeah but I meant if the batch file moved from a directory, without having to type the path in again?
  10. Scouse

    Scouse HERO! FH Subscriber

    Jeesus you're picky ;)
  11. Shovel

    Shovel Can't get enough of FH

    It should work if you just specify ".\output.log" as the log file and specify the full path for the del command. Then just run the script and it should appear alongside the script file.
  12. babs

    babs Can't get enough of FH

    yup, just prefix with .\

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.