I'm not sure this would cause it to loop forever, but you are writing to a NEW folder that is in the same hierarchy that you are reading from. So it will process files that you just wrote. You will need a filter to prevent that.
Also, I think your output file name needs %%~nxG
to get just the file name and extension, without the path.
There is a much simpler way to strip out blank lines. findstr . file
will strip out empty lines. findstr /rc:"[^ ]
will strip out empty lines and lines that contain only spaces.
@echo off
setlocal
set "outFolder=new"
for %%F in ("%outfolder%\.") for /r %%G in (*.txt) do if "%%~dpG" neq "%%~fF\" findstr /rc:"[^ ]" "%%G" >"%%~fF\%%~nxG"
But the simplest thing to do is just make sure your output folder is distinct from your source hierarchy
for /r %%G in (*.txt) do findstr /rc:"[^ ]" "%%G" >"\distinctPath\%%~nxG"
UPDATE
One thing that could cause your script to hang is that piped MORE will hang if the file has more than 64k lines. But I don't understand why you are using MORE in the first place.
more +1
removes the first line of every file? (might be your intention)