Search found 115 matches

by Yury
21 Nov 2016 16:25
Forum: DOS Batch Forum
Topic: Can someone write me a batch file to replace full stops in filenames, please?
Replies: 16
Views: 16370

Re: Can someone write me a batch file to replace full stops in filenames, please?

For number 2, the results would be: catgen.v1.0.zip becomes catgen v1.0.zip (just one full stop becomes a space) win.dirreplac.v.3.rar becomes win dirreplac v.3.rar (two full stops become spaces) t.c.s.2012.08.05.zip becomes t c s 2012.08.05.zip (three full stops become spaces) win.n64check.version...
by Yury
19 Nov 2016 09:10
Forum: DOS Batch Forum
Topic: Expand 2 variables at the same time
Replies: 5
Views: 6182

Re: Expand 2 variables at the same time

Code: Select all

setlocal

SET i=0
SET ARR[%i%]=1
SET /A "i+=1"
SET ARR[%i%]=2
SET /A "i+=1"
SET ARR[%i%]=3
SET ARR

SET len=%i%
SET i=0

IF YO EQU YO (
 cmd/v/c ECHO !ARR[%i%]!
 SET /A "i+=1"
 cmd/v/c cmd/v/c ECHO !ARR[!i!]!
)

endlocal
by Yury
19 Dec 2015 04:51
Forum: DOS Batch Forum
Topic: Problems with Batch-VBS Hybrid
Replies: 4
Views: 5801

Re: Problems with Batch-VBS Hybrid

Meerkat wrote:Is there any workaround on this?


Code: Select all

::'@echo off
remgoto rem
remrem Some codes here...
:rem
remecho This will be displayed!
rempause

remrem Some VBS codes here...
:) !
by Yury
20 Oct 2015 02:48
Forum: DOS Batch Forum
Topic: Search for String
Replies: 15
Views: 12472

Re: Search for String

@echo off set "t= " <"sample.txt">"After.txt" (for /f "tokens=3 delims=:" %%i in ('cmd/v/c "(for /l %%i in (1 1 3) do set/p x=)& echo !x!"') do for /f %%j in ("%%i") do (echo %%j ) for /f "skip=3 delims=" %%i in ('find "...
by Yury
19 Oct 2015 19:56
Forum: DOS Batch Forum
Topic: Search for String
Replies: 15
Views: 12472

Re: Search for String

@echo off set "t= " <"sample.txt">"After.txt" (for /f "tokens=3 delims=:" %%i in ('cmd/v/c "(for /l %%i in (1 1 3) do set/p x=)& echo !x!"') do for /f %%j in ("%%i") do (echo %%j ) for /f "delims=" %%i in ('find "|"...
by Yury
17 Oct 2015 16:02
Forum: DOS Batch Forum
Topic: Single line DOS commands and echoing formatted output
Replies: 6
Views: 6313

Re: Single line DOS commands and echoing formatted output

1. Double quotes and NUL are incompatible, even if your code is written syntactically correct, as the following code always displays that the folder does not exist: if exist "my junk\nul" (echo [FolderExists=true]) else (echo [FolderExists=false]) . Use the code without NUL: if exist "...
by Yury
06 Sep 2015 12:02
Forum: DOS Batch Forum
Topic: Using PowerShell to check if URLs are valid
Replies: 16
Views: 29602

Re: Help Needed in PowerShell

Try the batch file with the more simple PowerShell code:

Code: Select all

@powershell "gc 'URL.txt'|%%{if($(Try{(iwr $_).StatusCode}Catch{}) -eq 200){$_}}|sc 'True_URL.txt'"
.
by Yury
04 Sep 2015 09:06
Forum: DOS Batch Forum
Topic: Problem with loop and composited new variable
Replies: 5
Views: 4924

Re: Problem with loop and composited new variable

Code: Select all

@echo off
setlocal enabledelayedexpansion
set "oldV=aaa bbb ccc ddd"
set "addV=wow_"
set "newV=%addV%!oldV: = %addV%!"
echo %newV%
by Yury
15 Aug 2015 09:02
Forum: DOS Batch Forum
Topic: Which commands (and how) fail when pipe is used.
Replies: 5
Views: 5234

Re: Which commands (and how) fail when pipe is used.

⋅ SET /P command does not read data from the keyboard, but from the lines placed after it. The same happen with PAUSE command (or any command that read data). Yes! But: @break| <con ( set/p "var=Enter the value of the variable: " cmd/c if defined var call echo "%%var%%"...
by Yury
15 Aug 2015 06:25
Forum: DOS Batch Forum
Topic: Which commands (and how) fail when pipe is used.
Replies: 5
Views: 5234

Re: Which commands (and how) fail when pipe is used.

Hi, npocmaka_ ! Do not use only the commands that do not work in the command prompt such as SHIFT SETLOCAL ENDLOCAL GOTO label CALL :label and also REM . The rest of the commands are working under certain conditions of using. Test this code: @echo off echo start echo. call :# argument exit/b :# brea...
by Yury
14 Aug 2015 23:33
Forum: DOS Batch Forum
Topic: Fixed Width Text file
Replies: 17
Views: 13058

Re: Fixed Width Text file

Yuri, does your solution produce more spaces than required? Oh yeah ! This is the correct solution: @echo off setlocal enabledelayedexpansion set "in=in.txt" set "out=out.txt" set "template=2 15 19 4 38 35 13 15 2 10" for /f "delims=" %%i in ('forfiles /p &qu...
by Yury
14 Aug 2015 03:39
Forum: DOS Batch Forum
Topic: Fixed Width Text file
Replies: 17
Views: 13058

Re: Fixed Width Text file

@echo off setlocal enabledelayedexpansion set "in=in.txt" set "out=out.txt" set "template=2 15 19 4 38 35 13 15 2 10" for /f "delims=" %%i in ('forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo.0x09"') do set TAB=%%i for %%i in (%t...
by Yury
16 Jul 2015 13:09
Forum: DOS Batch Forum
Topic: Help with copying file to \sub\subdirectory
Replies: 4
Views: 5141

Re: Help with copying file to \sub\subdirectory

I need to do 2 things.. The first is to create a 'readme' folder in each of the subdirs, and then copy info.txt from \toplevel\ to the 'readme' subdir.. so the end result would be: toplevel\ toplevel\info.txt toplevel\subdir-01\readme\info.txt toplevel\subdir-02\readme\info.txt toplevel\subdir-03\r...
by Yury
06 Jul 2015 04:05
Forum: DOS Batch Forum
Topic: echo won't display spaces...
Replies: 3
Views: 4178

Re: echo won't display spaces...

The problem with this is that spaces aren't being displayed. You have problems not only with spaces, but also with quotes and with equal signs. To avoid all these problems try this code: @echo off set "firsttext="This is a test: hello world!"" for /f %%? in ('forfiles /p "%...
by Yury
06 Jul 2015 00:38
Forum: DOS Batch Forum
Topic: Add number List in For Loop without enabledelayedexpansion
Replies: 15
Views: 11473

Re: Add number List in For Loop without enabledelayedexpansi

Code: Select all

:GetCount
 set /a aCounter+=1
 if %aCounter% equ 1 for /f %%? in ('forfiles /m "%~nx0" /c "cmd /c echo 0x08"') do set BS=%%?
 set "aCounter=    %aCounter%"
 <nul set /p ="%BS%%aCounter:~-5% "
 goto :eof