Search found 115 matches

by Yury
24 Dec 2014 17:26
Forum: DOS Batch Forum
Topic: Looking for a BAT file to MOVE files into new folders
Replies: 3
Views: 1465

Re: Looking for a BAT file to MOVE files into new folders

<...> to be run in a DOS window (i.e. not the games program DOSBox, but a Windows prompt box) <...> I'm looking for a BAT file that creates folders (inside the current folder) and moves a given number of files into each sub folder. <...> I'd like a BAT file that I could put into that folder, run it...
by Yury
23 Dec 2014 14:11
Forum: DOS Batch Forum
Topic: Parentheses cause error
Replies: 5
Views: 1337

Re: Parentheses cause error

@echo off set "recstring=SOME TEXT with ( and ). Errors." goto %1 :1 echo 1 >outfile1.txt (cmd /v:on /c echo !recstring!) goto :EOF :2 echo 2 cmd /v:on /c echo !recstring!>outfile2.txt goto :EOF :3 echo 3 ( filepointer.exe 1 0 cmd /v:on /c echo !recstring! )>outfile3.txt echo END
by Yury
23 Dec 2014 12:53
Forum: DOS Batch Forum
Topic: set /p problems with pipes
Replies: 26
Views: 5808

Re: set /p problems with pipes

Code: Select all

@echo off
(
 for /l %%n in (1 1 10) do @echo Line%%n&>nul timeout 1
)|(
 for /l %%n in (1 1 10) do @(
  set var=empty
  set /p var=
  set var
 )
)


var=Line1
var=Line2
var=Line3
var=Line4
var=Line5
var=Line6
var=Line7
var=Line8
var=Line9
var=Line10
by Yury
22 Dec 2014 16:13
Forum: DOS Batch Forum
Topic: Detecting Process ID of the current cmd.exe
Replies: 46
Views: 46446

Re: Detecting Process ID of the current cmd.exe

dbenham , what should I do with your code to run it in a batch file that has the name " &ABC.bat "? I put my posted code within a file named "&abc.bat" and it works fine for me. I can run the script using either CALL "&ABC" or CALL ^&ABC. I found the re...
by Yury
22 Dec 2014 12:59
Forum: DOS Batch Forum
Topic: Detecting Process ID of the current cmd.exe
Replies: 46
Views: 46446

Re: Detecting Process ID of the current cmd.exe

The cmd.exe process does not have the batch script path in the command line if it was launched from an already running cmd.exe process. My code is just a special case of the detection process ID. I introduced a pause at the top of the script, and launched two processes via double clicking the scrip...
by Yury
21 Dec 2014 12:46
Forum: DOS Batch Forum
Topic: Detecting Process ID of the current cmd.exe
Replies: 46
Views: 46446

Re: Detecting Process ID of the current cmd.exe

@echo off& setlocal enableextensions enabledelayedexpansion set "f=%~f0" set d=00000000000000.000000+000 for /f "skip=1" %%i in (' wmic process where "Name='cmd.exe' and CommandLine like '%%%f:\=\\%%%'" get CreationDate ') do ( for /f %%j in ("%%i") do if...
by Yury
19 Dec 2014 13:26
Forum: DOS Batch Forum
Topic: Need help troubleshooting!
Replies: 3
Views: 944

Re: Need help troubleshooting!

Squashman wrote:fsutil requires admin privileges. A normal user will not even be able to run your batch file without running an elevated CMD prompt.


But not in Windows 8.1. I myself was surprised.


Squashman wrote:Good way to attempt to piss someone off by filling up their hard drive. I really dislike script kiddies.


+1
by Yury
17 Dec 2014 17:51
Forum: DOS Batch Forum
Topic: Best ways to redirect to log from within the batch
Replies: 5
Views: 1165

Re: Best ways to redirect to log from within the batch

JDAIII wrote:I would like something simple that I can add to the beginning of the .bat file without too much trouble.



Code: Select all

@rem:>&3 3>"example.log"

echo Hello, world!
timeout 3
start "" notepad "example.log"
exit /b
by Yury
16 Dec 2014 18:36
Forum: DOS Batch Forum
Topic: findstr errorlevel
Replies: 8
Views: 3975

Re: findstr errorlevel

Code: Select all

@echo off

for /f "delims=" %%i in ('dir /a-d/b "A"') do echo _%%i>>.tmp

echo Match:
dir /a-d/b "B"| findstr /eilg:.tmp

echo.

echo Don't match:
dir /a-d/b "B"| findstr /eilvg:.tmp

pause>nul
del .tmp
exit /b
by Yury
06 Dec 2014 04:11
Forum: DOS Batch Forum
Topic: plz help me now! read and show text ?
Replies: 10
Views: 1818

Re: plz help me now! read and show text ?

Code: Select all

@for /f "usebackq delims=" %%i in ("a.txt") do @echo %%~nxi
by Yury
05 Dec 2014 18:23
Forum: DOS Batch Forum
Topic: plz help me now! read and show text ?
Replies: 10
Views: 1818

Re: plz help me now! read and show text ?

One more way:

Code: Select all

@for /f %%i in ('cmd /u /c type "a.txt"^| more^| findstr [0-9]') do @<nul set /p=%%i
.
by Yury
05 Dec 2014 09:38
Forum: DOS Batch Forum
Topic: For Loop Question
Replies: 10
Views: 1904

Re: For Loop Question

*
by Yury
05 Dec 2014 06:27
Forum: DOS Batch Forum
Topic: plz help me now! read and show text ?
Replies: 10
Views: 1818

Re: plz help me now! read and show text ?

Code: Select all

@for /f %%i in ('"<a.txt set /p x=& call set /a %%x:*.=%%"') do @echo %%i
by Yury
27 Nov 2014 15:04
Forum: DOS Batch Forum
Topic: Batch script to copy 0 byte and non 0 byte to another dir
Replies: 10
Views: 2609

Re: Batch script to copy 0 byte and non 0 byte to another di

@echo off set "from=D:\Test 2" set "to=D:\Test 1" set masks_1=*.RAW *.XML set masks_2=*. pushd "%from%" for /f "tokens=1*" %%i in ('robocopy . %random% %masks_1% /nc /ndl /njh /njs /l') do if %%i==0 >nul move /y "%%j" "%to%" for /f "d...
by Yury
27 Nov 2014 10:19
Forum: DOS Batch Forum
Topic: Iterate volume letters to find ID
Replies: 7
Views: 1372

Re: Iterate volume letters to find ID

Is it possible to replace (z y x w v u t s r q p o n m l k j i h g f e d c b a) part with regular expression (to go through every letter in alphabet)? for /l %%# in (90 -1 65) do cmd /c exit /b %%#& 2>nul call vol %%=ExitCodeAscii%%:|>nul find "blah"&& call set tdrive=%%=ExitC...