Search found 951 matches

by jeb
19 Jan 2009 13:33
Forum: DOS Batch Forum
Topic: Compare Strings
Replies: 2
Views: 3881

Hi osramos, the findstr seems to be the right way. But then you have to use the output and split it with the FOR /F "tokens=..." command. Somthing like FOR /F "tokens=7" %%a in ('findstr "attempted" myFile.tmp') do set att=%%a FOR /F "tokens=7" %%c in ...
by jeb
19 Jan 2009 08:35
Forum: DOS Batch Forum
Topic: Help - How to find a character position in a string
Replies: 1
Views: 2953

Hi ibexcentral,

read the forum and you will find it.

Title: "Find index of substring or character in string."

jeb

[/url]
by jeb
18 Jan 2009 15:00
Forum: DOS Batch Forum
Topic: Extract rows from text file and slight reformatting
Replies: 10
Views: 7251

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: 4680

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: 4187

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: 4001

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: 4187

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: 8855

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: 8855

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: 7251

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: 11063

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: 3175

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: 4147

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: 8438

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: 3797

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...