#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    1
    Rep Power
    0

    Question Ignore errors in batch files?


    I am trying to write a batch file that will start at Drive A, search for files with the extension of FDB and make a list of those filenames and paths, and save to a text file. If there is no disk or flash drive, I prefer it continue, not stop with a fatal error.
    Example:
    A:
    cd\
    DIR *.FDB/S/B > C:\FDBDATA\ADATA.DAT
    B:
    cd\
    DIR *.FDB/S/B > C:\FDBDATA\BDATA.DAT
    C:
    cd\
    DIR *.FDB/S/B > C:\FDBDATA\CDATA.DAT

    ...and so on until Drive Z.

    At the end of creating the files, I can combine them to make one data file. This is the file I am looking for.

    My efforts fail when there is no floppy, flash, or pen diskette/drive in those letters. When there is no floppy/pen, I would prefer it just try the next letter and keep on going.

    After creating those files, I can combine them and use them for a genealogy program. It would be nice if this would run minimized so a new user won't get stressed at seeing all the commands.

    Any ideas please?

    Thank you very much.

    Abatch User
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    1
    Rep Power
    0
    Try something like (for drive A)

    Dir A:
    If NOT errorlevel 1 Dir A: *.FDB/S/B > C:\FDBDATA\ADATA.DAT

    This should only execute the Dir A: *.FDB/S/B > C:\FDBDATA\ADATA.DAT command if the drive exists. May need some tweaking.

    Hope this helps

    Ludwigvolcano


    Originally Posted by Abatch User
    I am trying to write a batch file that will start at Drive A, search for files with the extension of FDB and make a list of those filenames and paths, and save to a text file. If there is no disk or flash drive, I prefer it continue, not stop with a fatal error.
    Example:
    A:
    cd\
    DIR *.FDB/S/B > C:\FDBDATA\ADATA.DAT
    B:
    cd\
    DIR *.FDB/S/B > C:\FDBDATA\BDATA.DAT
    C:
    cd\
    DIR *.FDB/S/B > C:\FDBDATA\CDATA.DAT

    ...and so on until Drive Z.

    At the end of creating the files, I can combine them to make one data file. This is the file I am looking for.

    My efforts fail when there is no floppy, flash, or pen diskette/drive in those letters. When there is no floppy/pen, I would prefer it just try the next letter and keep on going.

    After creating those files, I can combine them and use them for a genealogy program. It would be nice if this would run minimized so a new user won't get stressed at seeing all the commands.

    Any ideas please?

    Thank you very much.

    Abatch User
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    re: Ignore errors in batch files?


    Hello,

    I think you can ignore errors in batch files by using proper code.

    Thanks for providing information
    John Farris

    Comments on this post

    • f_nietzsche disagrees : by using proper code...you think? SPAM!

IMN logo majestic logo threadwatch logo seochat tools logo