Results 1 to 9 of 9
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Useful Batch Files (Win XP (Home Edition))

    Hi,

    I've never really had the need to delve into batch files, so I do admit my ignorance regarding them. However, I had the need to "create" a simple .bat file the other day to delete all the files in a backup file system on my C: drive that I have been maintaining! I like to keep a common directory system, and whenever I have a file or dozen I wanna keep, I slot it into the appropriate directory...and then the next time I backup to CD, I point to the Backup_Dir on my C: and use Nero to burn the files to the same Dir system on my backup disk!

    After the backup I need to delete all the files in the Backup_Dir. As this system contains a fair amount of sub-directories, it's started becoming an issue to open all the subs, and delete the files...one sub at a time. (I wanted all files deleted in a large subdirectoy system!)

    So, I read up about batch files and Windows Help gave me a bit to go on. I created a little batch file with this one liner : C:Backup_Dir*.* /s.
    This did the job beautifully and quickly... All I needed to do was type "Y" as it confirmed the delete of each subdirectory!

    Seeing that I was pretty chuffed with my first .bat file, and that it did the job so well...I was wondering if there is not any other "common task" or "useful" batch files that any loungers can share with us! Maybe we can tweak them slightly and make 'em work for our needs too!!! Anyone care to share some useful .bat files!

    TIA
    Regards,
    Rudi

  2. #2
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Useful Batch Files (Win XP (Home Edition))

    <hr>...with this one liner : <big>C:Backup_Dir*.* /s</big>. This did the job beautifully and quickly...<hr>
    I don't see what that line does. Did you leave something out?

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Useful Batch Files (Win XP (Home Edition))

    Yes...sorry!

    It should be : <big>DEL C:Backup_Dir*.* /s</big>
    Regards,
    Rudi

  4. #4
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Useful Batch Files (Win XP (Home Edition))

    I see. If you add the /q switch you should be able to avoid the confirming prompt, I think.

    Take a gander <!post=at this thread,366948>at this thread<!/post> for a number of readings, most from our Batch File Commander-in-Chief, John Gray!

  5. #5
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Useful Batch Files (Win XP (Home Edition))

    Thanx BigAl. I gandered through them, and it looks VERY technical. I seems to be a good resource for the future though. Thanx for the link; as I browse more..I pick up more info and it all starts becoming a little more familiar!
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Regards,
    Rudi

  6. #6
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Useful Batch Files (Win XP (Home Edition))

    I see that you've already read the previous post, so I will add another rather than editing. I hope, since you've said you're new at this, that you won't take offense at a couple of additional comments. You do know that if you open a CMD prompt window and type a "DOS" command with the /? switch you'll usually get a list of the command's syntax, such as DEL /?.

    Also, I urge you to exercise as much care as you can when experimenting with batch files. Sometimes it's wise to test a new batch file on an experimental directory or by using a non-destructive command if possible. There's nothing more sickening than to realize you've erased a whole tree of files when you didn't mean to do so.

  7. #7
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Useful Batch Files (Win XP (Home Edition))

    Yes...thanx. In my reading up on WinXp's Help files, I noticed the option to use the Whatever_Command /? switch. It is useful!

    <hr>Also, I urge you to exercise as much care as you can when experimenting with batch files. Sometimes it's wise to test a new batch file on an experimental directory or by using a non-destructive command if possible.<hr>
    I am very aware here. I made absolutely certain the other day that I had a Test directory in which I copied some expendible subs and files into. All my tests were done on this folder first! Thanx for the advice....it is worth stressing this again and again!!

    Cheers
    Regards,
    Rudi

  8. #8
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Useful Batch Files (Win XP (Home Edition))

    And on what I hope you'll see some humor in, here's a zip file with an OLD batch file I wrote, way back when, for someone. It's in a zip file because of my use of a "bad word" in the batch file name. It was intended only to show someone how to make a quick backup copy of a few select files, but it also includes a little "branching" that you may not have encountered yet.

  9. #9
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Useful Batch Files (Win XP (Home Edition))

    Cheers BigAl...I'll have a sneek view of it (with one eye closed!) <img src=/S/noevil.gif border=0 alt=noevil width=25 height=17>
    Regards,
    Rudi

Posting Permissions

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