Search found 117 matches

by tinfanide
10 May 2012 23:51
Forum: DOS Batch Forum
Topic: Can't explain the error!
Replies: 8
Views: 6578

Re: Can't explain the error!

@ECHO ON setlocal enableDelayedExpansion FOR /L %%N IN (0,1,2) DO ( set skip=%%N set "word1=" REM set "word2=" FOR /F "tokens=*" %%A IN ('MORE +!skip! 1.txt') DO IF NOT DEFINED word1 SET "word1=%%A" ECHO !word1! FOR /F "tokens=*" %%B IN ('MORE +!ski...
by tinfanide
10 May 2012 09:18
Forum: DOS Batch Forum
Topic: Can't explain the error!
Replies: 8
Views: 6578

Re: Can't explain the error!

Try enabling delayed expansion and enclose the variables in quotes or brackets. @ECHO OFF setlocal enableDelayedExpansion FOR /L %%N IN (0,1,2) DO ( FOR /F "tokens=*" %%A IN ('MORE +%%N 1.txt') DO SET "word1=%%A"&GOTO :next :next FOR /F "tokens=*" %%B IN ('MORE +%%...
by tinfanide
10 May 2012 08:41
Forum: DOS Batch Forum
Topic: Can't explain the error!
Replies: 8
Views: 6578

Can't explain the error!

@ECHO OFF FOR /L %%N IN (0,1,2) DO ( FOR /F "tokens=*" %%A IN ('MORE +%%N 1.txt') DO SET "word1=%%A"&GOTO :next :next FOR /F "tokens=*" %%B IN ('MORE +%%N 2.txt') DO SET "word2=%%B"&GOTO :end :end IF %word1%==%word2% ( ECHO yes ) ELSE ( ECHO no ) ) PA...
by tinfanide
21 Apr 2012 17:23
Forum: DOS Batch Forum
Topic: The system cannot find the path specified???
Replies: 2
Views: 3612

Re: The system cannot find the path specified???

Please change your code to: FOR /F "tokens=3 skip=4" %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') DO CALL CD /D %%A The CALL command dissolve the "%USERPROFILE%". With CD /D command will change also the dr...
by tinfanide
21 Apr 2012 14:23
Forum: DOS Batch Forum
Topic: The system cannot find the path specified???
Replies: 2
Views: 3612

The system cannot find the path specified???

@ECHO ON CD C:\ FOR /F "tokens=3 skip=4" %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') DO CD %%A REM should return REM %USERPROFILE%\Desktop REM for English-version Windows PAUSE I have no idea why it doesn't work wi...
by tinfanide
16 Apr 2012 05:23
Forum: DOS Batch Forum
Topic: Missing operator???
Replies: 3
Views: 5114

Re: Missing operator???

Is this just trying to do exponents? Either try "exit /b" for "GOTO :EOF" or: @echo off set base=3 set mult=%base% set power=3 for /l %%a in (2,1,%power%) do set /a mult*=%base% echo %mult% pause Both ideas untested, though. Yes, tested. It works. Thank you. Based on your script...
by tinfanide
15 Apr 2012 08:51
Forum: DOS Batch Forum
Topic: Missing operator???
Replies: 3
Views: 5114

Re: Missing operator???

Thanks to aGerman in the previous post. SETLOCAL ENABLEDELAYEDEXPANSION does expand the run-time variable, if the wordings are correct technically. @ECHO ON SETLOCAL ENABLEDELAYEDEXPANSION SET base=3 SET power=3 FOR /L %%A IN (1,1,%power%) DO CALL :Count %%A ENDLOCAL PAUSE GOTO :EOF :Count index SET...
by tinfanide
15 Apr 2012 08:49
Forum: DOS Batch Forum
Topic: was unexpected at this time???
Replies: 5
Views: 24603

Re: was unexpected at this time???

aGerman wrote:Variable skip is assigned inside of the else block. Each environment variable assigned in the same command line or block does not expand to the value except you would use EnableDelayedExpansion ...

Regards
aGerman


Yes, a common mistake.
Thanks, aGerman.
by tinfanide
15 Apr 2012 08:46
Forum: DOS Batch Forum
Topic: Missing operator???
Replies: 3
Views: 5114

Missing operator???

@ECHO ON SET base=3 SET power=3 FOR /L %%A IN (1,1,%power%) DO CALL :Count %%A PAUSE GOTO :EOF :Count index SET /A times=%1-1 IF NOT %times%==0 ( CALL :ToPower %base% %times% SET /A skip=10-%n% ECHO %skip% ) PAUSE GOTO :EOF :ToPower SET n=1 FOR /L %%C IN (1,1,%2) DO SET /A n*=%1 GOTO :EOF PAUSE C:\...
by tinfanide
15 Apr 2012 08:38
Forum: DOS Batch Forum
Topic: was unexpected at this time???
Replies: 5
Views: 24603

Re: was unexpected at this time???

::@echo off REM SET /P base="How many directory(s) at each level? " REM SET /P power="How many time(s) / level(s) of directories? " SET base=3 SET power=4 :Control FOR /L %%Z IN (1,1,%power%) DO CALL :CreateDirectories %%Z PAUSE GOTO :EOF :CreateDirectories index IF NOT EXIST %~...
by tinfanide
15 Apr 2012 08:17
Forum: DOS Batch Forum
Topic: was unexpected at this time???
Replies: 5
Views: 24603

was unexpected at this time???

@ECHO ON SET base=3 SET power=4 :Control FOR /L %%Z IN (1,1,%power%) DO CALL :CreateDirectories %%Z PAUSE GOTO :EOF :CreateDirectories index IF NOT EXIST %~dp0log.log ( CALL :Make ) ELSE ( SET /A times=%1-1 CALL :CountLines CALL :ToPower %base% %times% SET /A skip=%lines%-%n% IF %skip% EQU 0 ( FOR ...
by tinfanide
12 Apr 2012 09:45
Forum: DOS Batch Forum
Topic: Any simpler way towards "To the power of..." in DOS?
Replies: 3
Views: 3635

Re: Any simpler way towards "To the power of..." in DOS?

Yes, no need to use EnableDelayedExpansion.
And still reading those complicated codes... hardest ever to me... :roll:
by tinfanide
11 Apr 2012 10:51
Forum: DOS Batch Forum
Topic: Any simpler way towards "To the power of..." in DOS?
Replies: 3
Views: 3635

Any simpler way towards "To the power of..." in DOS?

Code: Select all

@ECHO OFF

CALL :ToPower 3 2
GOTO :EOF

:ToPower
SETLOCAL ENABLEDELAYEDEXPANSION

SET /A n=1
FOR /L %%A IN (1,1,%2) DO SET /A n=!n!*%1
ECHO !n!

ENDLOCAL
GOTO :EOF


Any simpler way in DOS?
Arithmetic operators for powering a number?
by tinfanide
07 Apr 2012 19:32
Forum: DOS Batch Forum
Topic: Get Text in Cetrain Lines?
Replies: 6
Views: 5136

Re: Get Text in Cetrain Lines?

@echo off set line=5 call :GetLine %line% pause goto :EOF :GetLine set /A skip=%1-1 if %skip% gtr 0 ( set skip=skip=%skip% ) else ( set skip= ) for /F "%skip% delims=" %%a in (words.txt) do ( echo %%a exit /B ) Yes, they can be all done by skip, MORE or setting a counter. Thanks a lot.
by tinfanide
07 Apr 2012 09:09
Forum: DOS Batch Forum
Topic: Get Text in Cetrain Lines?
Replies: 6
Views: 5136

Re: Get Text in Cetrain Lines?

Yes, thanks for your examples. This teaches me more about how to make use of MORE. I used to be unable to make use of MORE because it lists the rest of the lines starting from +_LineNumber. But with the SET var=, it's possible to extract only that line much like the use of "break" in the J...