Batch spliting wrong formatted if statements

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bufoss
Posts: 8
Joined: 22 Nov 2016 13:46

Batch spliting wrong formatted if statements

#1 Post by bufoss » 09 Nov 2017 02:06

Hi all,
I have a folder with .sql files.

Inside the scripts there are well formatted and not well formatted "if statements"

To be more specific there are if statements which are all in the same line.
.i.e.

Code: Select all

IF  CONDITION  THEN  STATEMENT1; END IF;    

(the stament can be also in lower case)

Could you help me to make a batch modifying the above case
to

Code: Select all

IF  CONDITION  THEN  
  STATEMENT1; 
END IF;

Code: Select all

@echo off&cls

setlocal enabledelayedexpansion

echo. Checking files ... Do not close until end

for %%a in (*.sql) do (
   ........
)
echo. Finished

pause


Thank you

--------------
Real case :
IF NOT CUR1%ISOPEN THEN RETURN; END IF;
iF v_a + v_b < 5 then find_min ; end If;

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch spliting wrong formatted if statements

#2 Post by penpen » 09 Nov 2017 02:36

You might use Dave's "JREPL.BAT" to insert a line-ending ("\r\n" in c-style) after "THEN" and before "END IF;":
http://www.dostips.com/forum/viewtopic.php?f=3&t=6044.

penpen

Post Reply