Search found 115 matches

by Yury
27 Oct 2014 21:12
Forum: DOS Batch Forum
Topic: Trouble Setting Variable in For Loop
Replies: 11
Views: 7199

Re: Trouble Setting Variable in For Loop

The another way: @echo off setlocal enabledelayedexpansion for /f "delims=" %%G in ('dir /a-d/b *.txt') do ( set Filename=%%~nG for /f "tokens=2 delims=|" %%H in ("!Filename:--=|!") do ( set FourDigitNumber=%%H echo Four Digit Number: !FourDigitNumber! ) ) endlocal paus...
by Yury
27 Oct 2014 20:52
Forum: DOS Batch Forum
Topic: Trouble Setting Variable in For Loop
Replies: 11
Views: 7199

Re: Trouble Setting Variable in For Loop

Code: Select all

for /f "delims=" %%G in ('dir /a-d/b *.txt') do (
 set Filename=%%~nG
 for /f "tokens=2 delims=|" %%H in ('call set /p"=%%Filename:--=|%%"^<nul') do (
  set FourDigitNumber=%%H
  call echo Four Digit Number: %%FourDigitNumber%%
  )
 )
by Yury
27 Oct 2014 20:30
Forum: DOS Batch Forum
Topic: Trouble Setting Variable in For Loop
Replies: 11
Views: 7199

Re: Trouble Setting Variable in For Loop

Code: Select all

@echo off

for /f "delims=" %%G in ('dir /a-d/b *.txt') do (
 set Filename=%%~nG
 for /f "tokens=2 delims=|" %%H in ('call set /p"=%%Filename:--=|%%"^<nul') do (
  echo Four Digit Number: %%H
  )
 )

pause>nul
exit /b
by Yury
21 Oct 2014 03:04
Forum: DOS Batch Forum
Topic: Random number
Replies: 1
Views: 2397

Re: Random number

Code: Select all

@echo off
setlocal enabledelayedexpansion

for /l %%i in (1 1 100) do (
 set var=0000!random!
 echo !var:~-5!
 )

endlocal
pause>nul
exit /b
by Yury
20 Oct 2014 15:47
Forum: DOS Batch Forum
Topic: commands a 30 minute time pause
Replies: 8
Views: 6598

Re: commands a 30 minute time pause

TIMEOUT /? TIMEOUT [/T] timeout [/NOBREAK] Description: This utility accepts a timeout parameter to wait for the specified time period (in seconds) or until any key is pressed. It also accepts a parameter to ignore the key press. Parameter List: /T timeout Specifies the number of seconds to wait. V...
by Yury
20 Oct 2014 04:11
Forum: DOS Batch Forum
Topic: Sort Records
Replies: 12
Views: 7142

Re: Sort Records

<"example.txt" more +1| sort /+10 /o "example.txt" Yury, I think the OP wants to preserve the 1st line too. rem There are 11 spaces before the "!header!". <"example.txt" (set /p "header="& more +1& cmd /v:on /c echo !header!)| sort /+10 /o &...
by Yury
20 Oct 2014 03:13
Forum: DOS Batch Forum
Topic: [Win 8.x] Robocopy and same directory
Replies: 2
Views: 2443

Re: [Win 8.x] Robocopy and same directory

Code: Select all

@echo off

set "dir=D:\Test"
set "source=example.txt"
set "dest=new.txt"

pushd "%dir%"
>nul robocopy . temp "%source%"
>nul move "temp\%source%" "%dest%"
rd temp
popd

exit /b
by Yury
20 Oct 2014 01:28
Forum: DOS Batch Forum
Topic: Sort Records
Replies: 12
Views: 7142

Re: Sort Records

Thanks Squashman, Still i face a difficulty the file is of approx. 4/5 thosuand rows and it takes a lot of time to complete, is there a faster/max way to do that. Is it necessary to output to other file can't it be performed directly on itself. Sorting to start from line 2 as top is header. <"...
by Yury
19 Oct 2014 13:31
Forum: DOS Batch Forum
Topic: Sort Records
Replies: 12
Views: 7142

Re: Sort Records

Code: Select all

sort /+10 "example.txt"
by Yury
18 Oct 2014 04:00
Forum: DOS Batch Forum
Topic: Extract only the last word from a string
Replies: 5
Views: 9915

Re: Extract only the last word from a string

Put an ampersand in there and BANG! Without the Bing Bang: @echo off setlocal enabledelayedexpansion set "string=|| <> :&" for /f "delims=" %%i in ('cmd /u /c set /p"=%string%"^<nul^| more^| findstr /n "^"') do ( set symbol=%%i if not "!symbol:*:=!&q...
by Yury
18 Oct 2014 02:55
Forum: DOS Batch Forum
Topic: changing all the file names' case in a directory to UPPER
Replies: 11
Views: 12307

Re: changing all the file names' case in a directory to UPPE

rafi401 wrote:Also i am trying to change the files's case to lower.. but with no luck



Code: Select all

@echo off

echo Enter the directory.
echo.
set /p "dir="

pushd "%dir%"
for /f "delims=" %%i in ('"dir /a-d/b/l 2>nul"') do ren "%%i" "%%i"
popd

exit /b
by Yury
18 Oct 2014 02:38
Forum: DOS Batch Forum
Topic: changing all the file names' case in a directory to UPPER
Replies: 11
Views: 12307

Re: changing all the file names' case in a directory to UPPE

Is there any option to set/fetch the directory in the script dynamically? @echo off echo Enter the directory. echo. set /p "dir=" pushd "%dir%" for /f "tokens=* delims=- " %%i in ('for /f "delims=" %%j in ^('"dir /a-d/b 2>nul"'^) do @find "&quo...
by Yury
17 Oct 2014 12:38
Forum: DOS Batch Forum
Topic: Batch file to check a process that running on other PC
Replies: 12
Views: 7496

Re: Batch file to check a process that running on other PC

@echo off setlocal enabledelayedexpansion set _password=P$5$C$^^^^^^!3 set _password echo "%_password%" echo. set "_password=P$5$C$^^^!3" set _password echo "%_password%" echo. set _password="P$5$C$^^^!3" set _password echo %_password% echo. set _password=P$5...
by Yury
17 Oct 2014 08:28
Forum: DOS Batch Forum
Topic: changing all the file names' case in a directory to UPPER
Replies: 11
Views: 12307

Re: changing all the file names' case in a directory to UPPE

I have perfected and shortened my code. Now it does not depend on the code page and ASCII symbols in file names: @echo off set "dir=D:\Test" pushd "%dir%" for /f "tokens=* delims=- " %%i in ('for /f "delims=" %%j in ^('"dir /a-d/b "%dir%" 2>nul&...
by Yury
17 Oct 2014 05:36
Forum: DOS Batch Forum
Topic: changing all the file names' case in a directory to UPPER
Replies: 11
Views: 12307

Re: changing all the file names' case in a directory to UPPE

However, can you please tell me how to rename the files present in the directory from Lower Case to UPPER CASE. @echo off set "dir=D:\Test" chcp 1252>nul pushd "%dir%" for /f "tokens=1* delims=-" %%i in ('for /f "delims=" %%k in ^('"dir /a-d/b "%dir...