MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Avoid generating an existing file
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Avoid generating an existing file

 Post Reply Post Reply
Author
Message
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Topic: Avoid generating an existing file
    Posted: 19.Nov.2010 at 14:20

When generating a file, the MetaEdit+ generator will look to see if that file already exists. If so, and the generated output would be the same as the contents of the existing file, it will not overwrite the existing file. This ensures that the timestamp of the file is not changed unnecessarily, so incremental build / make works well.

You can also make MetaEdit+ not generate a file if it already exists, even if the contents are different. You can use external…executeBlocking to run a batch/shell file to list all files in the directory, saving the results in a file, and then read that file into a variable with variable...write filename...read close. Here's an example for Windows; a shell script would be similar.

$filename='fileA.txt'
subreport '_translators' run

external 'cmd /x /c echo.>dir.txt && dir /b>>dir.txt' executeBlocking

variable 'dir' write
   filename 'dir.txt' read
close

/* $dir contains all files, one per line, with blank line at start & end */
if $dir =~ $filename%wildnl then
   $filename ' already exists, do not generate it'
else
   $filename ' does not exist, generate it here'
endif

You can search $dir for other filenames in a similar way. The "echo.>dir.txt" part makes sure there is a blank line at the start; this is needed because we search for $filename with a newline before and after it, to make sure we don’t mistakenly find "bar.doc" within a line "foobar.docx".

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.023 seconds.