Print Page | Close Window

Avoid generating an existing file

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=183
Printed Date: 27.Mar.2026 at 00:26
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Avoid generating an existing file
Posted By: stevek
Subject: Avoid generating an existing file
Date 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".




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net