Search found 3479 matches

by aGerman
23 May 2019 10:50
Forum: DOS Batch Forum
Topic: Loop through file to find and replace
Replies: 1
Views: 39

Re: Loop through file to find and replace

set /a "flag_ip=0, flag_dns=0" for /f "delims=" %%i in ('findstr /n "^" "%iniFile%" ^& break ^> "%iniFile%" ') do ( set "line=%%i" setlocal enabledelayedexpansion set "line=!line:*:=!" if "!line:~-22!"=="%ultra%" ( >>"%iniFile%" echo(!line:%ultra%=%onPrem%! set /a "flag_ip=1" ) else if "!line:~-29!...
by aGerman
20 May 2019 11:54
Forum: DOS Batch Forum
Topic: Delete unwanted time strings
Replies: 1
Views: 43

Re: Delete unwanted time strings

Try that piece of code:

Code: Select all

@echo off &setlocal
set "infile=test.csv"
set "outfile=updated.csv"

>"%outfile%" (for /f "usebackq tokens=1,3*" %%i in ("%infile%") do echo %%i %%k)
Is jrepl.bat able to make it?
For sure.

Code: Select all

call JREPL.bat " [0-2]\d(:[0-5]\d){2} -" "" /F "%infile%" /O "%outfile%"
Steffen
by aGerman
20 May 2019 10:02
Forum: DOS Batch Forum
Topic: Enable ANSI escape sequence within Windows 10 console
Replies: 7
Views: 234

Re: Enable ANSI escape sequence within Windows 10 console

I can't really tell. It saves the time wasted to write a temporary C# code and compile it into a DLL. Platform invocation (the 3 lines between the single quotes in #3) required that. At least for me removing platform invocation reduced the time by half. The first time I launch PowerShell within a g...
by aGerman
18 May 2019 18:45
Forum: DOS Batch Forum
Topic: Copying and renaming files with same name
Replies: 1
Views: 62

Re: Copying and renaming files with same name

In a batch script you could do it like that: @echo off &setlocal set "src=C:\source" set "dst=D:\destination" for /r "%src%" %%i in (*) do ( if not exist "%dst%\%%~nxi" ( copy "%%~i" "%dst%\" ) else ( set "fullname=%%~i" set "name=%%~ni" set "ext=%%~xi" set "idx=0" call :newname ) ) exit /b :newname...
by aGerman
17 May 2019 05:07
Forum: DOS Batch Forum
Topic: Enable ANSI escape sequence within Windows 10 console
Replies: 7
Views: 234

Re: Enable ANSI escape sequence within Windows 10 console

LOL :lol: New discovery ... Try var objExec = WScript.CreateObject("WScript.Shell").Exec("powershell.exe -nop -ep Bypass -c \"exit\""); while (objExec.Status == 0) {WScript.Sleep(50);} Once you run powershell.exe VT processing keeps being persistent. This is much faster :!: Unfortunately it doesn't ...
by aGerman
16 May 2019 12:37
Forum: DOS Batch Forum
Topic: Enable ANSI escape sequence within Windows 10 console
Replies: 7
Views: 234

Re: Enable ANSI escape sequence within Windows 10 console

Perhaps I can shave off a bit of the delay by initiating objExec early on, and postpone the while loop that checks the status until just before the main JREPL processing loop. Good idea :!: That reduced the delay to somewhat between a second or two when I tried it. I suspect that the new Windows Te...
by aGerman
16 May 2019 10:18
Forum: DOS Batch Forum
Topic: Enable ANSI escape sequence within Windows 10 console
Replies: 7
Views: 234

Re: Enable ANSI escape sequence within Windows 10 console

Dave, I hoped it would be possible to enable the VT mode in JREPL without updating the registry. Actually it works, but it's terribly slow. So, I'm afraid this is not an option :( For testing, add that piece of code at the beginning of the JScript portion: var objExec = WScript.CreateObject("WScript...
by aGerman
16 May 2019 10:02
Forum: DOS Batch Forum
Topic: Preparation before concatenation
Replies: 7
Views: 125

Re: Preparation before concatenation

What about that: for /f "delims=" %%i in ('dir /a-d /b *.m3u8*') do ( set "name=%%~ni" set "ext=%%~xi" setlocal EnableDelayedExpansion set /a "n=10000+!ext:~5!" move /y "!name!!ext!" "!name!!n:~-4!.m3u8" endlocal ) >"fullmovie.m3u8" type nul for /f "delims=" %%i in ('dir /a-d /b /on *.m3u8') do ( co...
by aGerman
15 May 2019 12:15
Forum: DOS Batch Forum
Topic: Enable ANSI escape sequence within Windows 10 console
Replies: 7
Views: 234

Re: Enable ANSI escape sequence within Windows 10 console

Recently I read about this registry value, looked it up on my machine, but didn't find it. Since VT processing works for me I realized it was enabled by the script interpreters (such as cmd and powershell). But I didn't think about other console utilities. Thanks for the heads-up, Dave!

Steffen
by aGerman
15 May 2019 09:43
Forum: DOS Batch Forum
Topic: Preparation before concatenation
Replies: 7
Views: 125

Re: Preparation before concatenation

You could try that loop ... for /f "delims=" %%i in ('dir /a-d /b *.m3u8*') do ( set "name=%%~ni" set "ext=%%~xi" setlocal EnableDelayedExpansion move /y "!name!!ext!" "!name!!ext:~5!.m3u8" endlocal ) ... but I'm afraid this will still not be the solution you are after, depending on how you proceed ...
by aGerman
13 May 2019 18:12
Forum: DOS Batch Forum
Topic: Wait till close by title
Replies: 2
Views: 91

Re: Wait till close by title

need you to:
1. turn it on
2. wait till it becomes blue
3. turn the other off

you don't know what I mean? so what, just do it
by aGerman
11 May 2019 11:23
Forum: DOS Batch Forum
Topic: Microsoft New Terminal - Thoughts???
Replies: 1
Views: 95

Re: Microsoft New Terminal - Thoughts???

As Turner and Niksa explained, they can't change the console itself any further because this would break downward compatibility. So, the terminal is just an app where you can run console applications in. This is somehow similar to existing 3rd party software like ConEmu. The new terminal has a few a...
by aGerman
10 May 2019 09:44
Forum: DOS Batch Forum
Topic: search - copy problem
Replies: 4
Views: 110

Re: search - copy problem

It isn't possible as long as you use the /g switch of findstr. Either you have to process your list line by line or you have to change the content of your list before you use it along with findstr /g.

Steffen
by aGerman
09 May 2019 10:14
Forum: DOS Batch Forum
Topic: search - copy problem
Replies: 4
Views: 110

Re: search - copy problem

Untested:

Code: Select all

for /f "usebackq delims=;" %%i in ("%sourceList%") do (
  for /f "delims=" %%j in ('2^>nul dir /a-d /b /s "%sourceRoot%\%%~i"') do copy "%%~j" "%destFolder%\"
)
That will fail if one of the file names contains a semicolon though.

Steffen
by aGerman
09 May 2019 10:07
Forum: DOS Batch Forum
Topic: Variable in FOR wont work
Replies: 1
Views: 66

Re: Variable in FOR wont work

Variables are expanded before a command line or a block of command lines (enclosed in parentheses) is executed. Thus, you can't output variables of variables that are defined or changed inside of the block in the default way. You need to enable delayed expansion and use exclamation points instead of...