edit 2500 text files to add three decimal places for integer number and decimal number where you can find after @x*

Simple using the JREPL.BAT regular expression text processing utility, coupled with a bit of custom JScript. I used a method described at http://www.jacklmoore.com/notes/rounding-in-javascript/ to reliably round decimal values. Without it, a value like 0.0008 would improperly round to 0.000.

@echo off
for %%F in (*.txt) do call jrepl "(@x\*)(\d+\.?\d*|\.d+)" "$1+Number(Math.round($2+'e'+3)+'e-'+3).toFixed(3)" /j /f "%%F" /o -

Leave a Comment