Important is, that every subfile is separated by $$$$
So the data look like: file test.sdf
line1
line2
line3
line4
$$$$
line6
line7
line8
line9
line10
$$$$
etc.
and I need have separated files
file1.mol
line1
line2
line3
line4
file2.mol
line6
line7
line8
line9
line10
etc.
I tried to write a script but it looks like it does not work. I will really appreciate if someone could help me. I am not comfortable with batch and rather use bash, but I need to learn something new…
here is my code:
@ECHO OFF
SET “destdir=C:\Users\miru\Desktop”
SET “extensions=mol”
SET “output=”
FOR /f “delims=” %%a IN (test.sdf) DO (
IF “%%a”==”$$$$” (SET “output=Y”&SET; “ext=”
) ELSE (
IF DEFINED output (
IF NOT DEFINED ext FOR %%s IN (%extensions%) DO IF /i “%%a”==”%%s” SET “ext=%%s”
)
)
GOTO :EOF
::======== begin batchscript
@echo off & setlocal enabledelayedexpansion
set c=0
for /f “tokens=*” %%a in (test.sdf) do (
if “%%a” equ “$$$$” (
set /a c+=1
:: this next is just to kill any lingering left-overs
>f!c!.mol echo.
) else (
>> f!c!.mol echo %%a
)
)
::===== end batchscript, limited testing