Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch file, to see if file/folder exist  (Read 102013 times)

0 Members and 1 Guest are viewing this topic.

aceee

    Topic Starter


    Newbie

    batch file, to see if file/folder exist
    « on: August 03, 2008, 09:59:32 PM »
    hey all..

    i'm trying to write a batch file to see if c:\folder exists.  If it doesn't create it.
    Then,

    See if myfile.ini exists... if it does not, create it, and put
    TEXT @@ TEXT
    TEXT2 @@ TEXT2
    in the file,
    then close
    and exit

    any ideas?

    Carbon Dudeoxide

    • Global Moderator

    • Mastermind
    • Thanked: 169
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Experience: Guru
    • OS: Mac OS
    Re: batch file, to see if file/folder exist
    « Reply #1 on: August 03, 2008, 10:28:45 PM »
    I've written the code but what is this going to be used for?

    aceee

      Topic Starter


      Newbie

      Re: batch file, to see if file/folder exist
      « Reply #2 on: August 03, 2008, 10:34:29 PM »
      lol guilty until proven inocent :)

      I have an excel file that automaticly saves files to a folder... but it errors out when the folder doesn't exist... so this is like an "Install" program to make sure... and the mytext.ini stores some of the text for the spread sheet

      Carbon Dudeoxide

      • Global Moderator

      • Mastermind
      • Thanked: 169
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Experience: Guru
      • OS: Mac OS
      Re: batch file, to see if file/folder exist
      « Reply #3 on: August 03, 2008, 11:05:22 PM »
      Quote
      lol guilty until proven inocent
      Yep  :P :P

      Try this:

      Code: [Select]
      @echo off
      if exist "C:\file.ini" (
      echo. File Exists
      pause
      exit
      ) else (
      echo Random Text >>"C:\file.ini"
      exit
      )


      You may have to adapt the code though.