C
C
Cyril2016-09-27 10:30:56
PHP
Cyril, 2016-09-27 10:30:56

How to extract data from text files using php or vbs?

Good afternoon, tell me how to parse certain lines from .cmd files, for example: script in file:
cd "%SD_EVENTHOME%bin"
call addentry.bat c:\SD\RG "%SD_EVENTHOME%bin\sd_event.exe" -a wo/ sDSddd -s servName -x "WO: OFEZ: (nyanNAME) Directory Control Authority" -c WO -m insert -l "C:\SD\wo_creation.log" -v "EXTID=REG%DATE% %TIME% %RANDOM %"
from all this, you only need to pull out this: "WO: OFEZ: (nyanNAME) Directory control organ"
the problem is that there are 390 files in total, among them there are both empty and commented out and partially commented out and one file with a bunch of scripts inside and one script at a time
, in the end, you need to unload something like this using the example of this file: script.cmd "WO: OFEZ: (nyanNAME) Directory Control Authority"
(i.e. the file in which lies / lies the script / scripts and the name itself which is in quotes)
I will be glad if you tell me how to do it in php

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Privalov, 2016-09-27
@negasus

Let's say all the files are in the same folder.
Then using opendir/readdir we get a list of files.
Next in the loop, read the file into a string and parse that string with a regular expression.
And in order to write the correct regular expression, you need to understand how these files can look inside.

R
res2001, 2016-09-27
@res2001

Do you only need php or vbs? Why not pull out the same body shirt?

@echo off
set "dirin=c:\temp"
set "findstr=addentry.bat"
for /f "tokens=1,* delims=:" %%a in ('findstr /c:"%findstr%" "%dirin%\*.cmd" ') do call:workstr %%~b
goto:eof

:workstr
shift
echo.script.cmd  %9
exit /b

More or less like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question