Checking if files exist

Checking if files exist

1
NewbieNewbie
1

    Jan 16, 2008#1

    Hi,

    I'm new to UltraEdit, and I've searched the forums for this, but haven't found anything yet.

    I have an index file of several million files and need to make sure that all of the files in the index actually exist. How can I loop through the entire file (over 2 million lines) and log to one text file when the file is found, but log to another text file when the file is not found?

    File example:
    \Folder\12345.fil
    \Folder\12346.fil
    \Folder\12348.fil
    \Folder\12349.fil
    \Folder\45\12345.fil
    \Folder\45\12346.fil
    \Folder\45\12349.fil
    \Folder\45\12348.fil

    Thanks!

    6,606548
    Grand MasterGrand Master
    6,606548

      Jan 16, 2008#2

      The following macro converts your list file into a batch file:

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Top
      TrimTrailingSpaces
      Find RegExp "%^(*^)$"
      Replace All "if exist "^1" echo ^1 >>_ExistingFiles.txt^pif not exist "^1" echo ^1 >>_MissingFiles.txt"
      "@echo off
      if exist _ExistingFiles.txt del _ExistingFiles.txt
      if exist _MissingFiles.txt del _MissingFiles.txt
      "
      SaveAs "FileTest.bat"

      Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.

      Your example (file FileTest.bat) will look after macro execution as follows:

      @echo off
      if exist _ExistingFiles.txt del _ExistingFiles.txt
      if exist _MissingFiles.txt del _MissingFiles.txt
      if exist "\Folder\12345.fil" echo \Folder\12345.fil >>_ExistingFiles.txt
      if not exist "\Folder\12345.fil" echo \Folder\12345.fil >>_MissingFiles.txt
      if exist "\Folder\12346.fil" echo \Folder\12346.fil >>_ExistingFiles.txt
      if not exist "\Folder\12346.fil" echo \Folder\12346.fil >>_MissingFiles.txt
      if exist "\Folder\12348.fil" echo \Folder\12348.fil >>_ExistingFiles.txt
      if not exist "\Folder\12348.fil" echo \Folder\12348.fil >>_MissingFiles.txt
      if exist "\Folder\12349.fil" echo \Folder\12349.fil >>_ExistingFiles.txt
      if not exist "\Folder\12349.fil" echo \Folder\12349.fil >>_MissingFiles.txt
      if exist "\Folder\45\12345.fil" echo \Folder\45\12345.fil >>_ExistingFiles.txt
      if not exist "\Folder\45\12345.fil" echo \Folder\45\12345.fil >>_MissingFiles.txt
      if exist "\Folder\45\12346.fil" echo \Folder\45\12346.fil >>_ExistingFiles.txt
      if not exist "\Folder\45\12346.fil" echo \Folder\45\12346.fil >>_MissingFiles.txt
      if exist "\Folder\45\12349.fil" echo \Folder\45\12349.fil >>_ExistingFiles.txt
      if not exist "\Folder\45\12349.fil" echo \Folder\45\12349.fil >>_MissingFiles.txt
      if exist "\Folder\45\12348.fil" echo \Folder\45\12348.fil >>_ExistingFiles.txt
      if not exist "\Folder\45\12348.fil" echo \Folder\45\12348.fil >>_MissingFiles.txt

      Run now this batch file by double clicking on it in Windows Explorer or by using Advanced - DOS Command. You will get the 2 files _ExistingFiles.txt and _MissingFiles.txt after batch file execution. _MissingFiles.txt will not exist if there are no missing files.
      Best regards from an UC/UE/UES for Windows user from Austria