Search found 964 matches

by jeb
18 Jan 2009 15:00
Forum: DOS Batch Forum
Topic: Extract rows from text file and slight reformatting
Replies: 10
Views: 7616

Hi NTY, so I try to find a hint. I build my own tmp.csv remark 1 remark 2 remark ... remark N City,Visits Hamburg,1 Berlin,8 Bochum,1000 This is the end, but should not used For /F %%A in ('Find /V /C "City,Visits" tmp.csv') Do set FR=%%A First, I tried "Find /V /C" and i...
by jeb
18 Jan 2009 14:11
Forum: DOS Batch Forum
Topic: Passing argument to DOS script containing a quote
Replies: 1
Views: 4795

Hi Harlod, simple if you use only one argument like the password. Then you can use %* for all the input. But if you use two arguments, like user and pwd, then it becomes complicated. The first argument is obviously %1, but the SHIFT command fail for %*. %* reflects always all arguments, not modified...
by jeb
12 Jan 2009 13:12
Forum: DOS Batch Forum
Topic: Variable Question
Replies: 4
Views: 4407

Hi Cander, hmm. The idea here was to get the connect1's variable value "1243" into the variable value? That's my intention. What does the triple %%% do? Why the call? The triple %%%, read it as (%%)%str%(%%), the rule is: %% will "expand" to a single % without any other meaning, ...
by jeb
05 Jan 2009 17:19
Forum: DOS Batch Forum
Topic: Parse path into drive/directory/file
Replies: 4
Views: 4153

Hi jpeg, look at the help of FOR (for /?), there is the substitution explained. setlocal set str=c:\parentdir\childdir\filename.ext call :split %str% goto :eof :split echo drive=%~d1 path=%~p1 name=%~n1 ext=%~x1 goto :eof Results to drive=c: path=\parentdir\childdir\ name=filename ext=.ext jeb
by jeb
05 Jan 2009 17:13
Forum: DOS Batch Forum
Topic: Variable Question
Replies: 4
Views: 4407

Hi Cander,

try this for indirect variable access

Code: Select all

set connect1=1243
set str=connect1

call set value=%%%str%%%
echo %value%


jeb
by jeb
05 Jan 2009 17:05
Forum: DOS Batch Forum
Topic: Relative path for subdirectories from dir command?
Replies: 4
Views: 9173

Hi, you got it, but you missed some few characters. I tested this and it seems to works. setlocal enabledelayedexpansion for /F "tokens=*" %%c in ('dir *.bmp /a-d /ogn /b /s') do ( set abspath=%%~fc call set "relpath=%%abspath:%cd%\=%%" rem echo abs=!abspath! rel=!rel...
by jeb
04 Jan 2009 18:15
Forum: DOS Batch Forum
Topic: Relative path for subdirectories from dir command?
Replies: 4
Views: 9173

Hi JubaJuba, look at :MakeRelative from the Function Library, use it with an absolute path to your file and it should work. for /F "tokens=*" %%c in ('dir *.jpg;*.bmp /a-d /ogn /b') do ( set filename=%%~fc call :MakeRelative filename echo ^<img^>!filename!^<^/img^> >> list.xml ...
by jeb
04 Jan 2009 18:07
Forum: DOS Batch Forum
Topic: Extract rows from text file and slight reformatting
Replies: 10
Views: 7616

Hi NYTReader123, try to use the FOR statement to extract single lines from the file. for /f "tokens=*" %%a in (tmp.csv) do @echo %%a But first you have to simple count the number of lines (also with the FOR), then it should be simple. Then you start a second FOR-run and append your...
by jeb
04 Jan 2009 17:59
Forum: DOS Batch Forum
Topic: Find index of substring or character in string.
Replies: 2
Views: 11571

Hi lstewart, try this setlocal set str=abcdefghijklmnopqrstuvxyz call :indexOf result "%str%" "e" echo %result% goto :eof :::::::::::::::::::::::::::::::::::::::::::::::::::: :indexOf <resultVar> <str> <find> SETLOCAL set "str=%~2" call set "part=%%str:%~3=&rem...
by jeb
04 Jan 2009 17:36
Forum: DOS Batch Forum
Topic: Moving files inside a folder
Replies: 1
Views: 3318

Hi BatchFileCommand,

do you get an error message?

Try to quote it, there could be spaces in the path to the Desktop

Code: Select all

move /-Y "%homedrive%\%homepath%\Desktop\File,..." HyperFolder


Hope it helps
jeb
by jeb
05 Dec 2008 04:59
Forum: DOS Batch Forum
Topic: Current line number being executed
Replies: 2
Views: 4335

Hi Jeff, I suppose there is no simple sulotion for __LINE__, but I use a pseudo line function for error messages like "Error in line 123: Invalid parameter". @echo off setlocal enableextensions rem setlocal enabledelayedexpansion if "%~1"=="" ( call :echoLine "...
by jeb
02 Jul 2008 08:34
Forum: DOS Batch Forum
Topic: Setting variable values and logging to a file
Replies: 9
Views: 8964

Hi, nice problem, but where is the problem? I tried this and it works REM *** Update log file and delete any tmp files and clean up @echo off setlocal if exist "deletelist.tmp" goto :doIt goto :eof :doIt set /a Q20=0 echo Q20=%Q20% set /a DATA=0 echo DATA=%DATA% echo File deletions started...
by jeb
24 Jun 2008 16:13
Forum: DOS Batch Forum
Topic: Need really simple code
Replies: 1
Views: 3946

Hi, build a file named IPList.txt like 192.168.0.1 10.0.47.11 10.0.08.15 ... Read the file and get the hostname @echo off setlocal enabledelayedextensions for /F "tokens=*" %%i IN (IPlist.txt) DO ( echo IP is %%i rem do something with this ip, like ping %%i rem echo the name pi...
by jeb
19 Jun 2008 00:08
Forum: DOS Batch Forum
Topic: How can I get the path to the batch file being run?
Replies: 1
Views: 3700

Hi Chris,

this should work

Code: Select all

echo path to %0 is %~dp0


jeb
by jeb
15 Jun 2008 00:18
Forum: DOS Batch Forum
Topic: challenge: a dos shell stopwatch
Replies: 5
Views: 8227

Hi davep, In my country the decimal point is a comma, thats not really a problem. But the rest can't work. Take the time at " 9:24:02,56" and " 9:25:02,56" this should result in 60.0 seconds, but your code results in 100.0 seconds. Next problem, try it with "0:28:24,56"...