Search found 237 matches

by DosItHelp
20 Feb 2009 23:14
Forum: DOS Batch Forum
Topic: How to use the :IsFileOpen, IsRegKey, IsRegValue, IsServiceR
Replies: 1
Views: 4378

mlwhitl, Yes, I can see it might need some more explanation... You could check ERRORLEVEL right after calling the function or simply use the && operator to react on success (service is running) or use the || operator to react on failure (service not running), like this: @Echo Off call:IsServ...
by DosItHelp
20 Feb 2009 22:42
Forum: DOS Batch Forum
Topic: Create my first batch file
Replies: 2
Views: 5399

JM,

Check out the FTP examples here: http://www.dostips.com/DtTipsFtpBatchScript.php
Hope this helps.
by DosItHelp
20 Feb 2009 22:39
Forum: DOS Batch Forum
Topic: assign result of findstr to variable
Replies: 2
Views: 8272

Good start RElliott63, The line with the set command needs some fixing. How about: SETLOCAL ENABLEEXTENSIONS SETLOCAL ENABLEDELAYEDEXPANSION For /F "delims=" %%s in ('Find "ABC" Test.txt') Do ( Set "Str=%%s" Set "Str=!s:~-3!" Call :DoSomethingWithS...
by DosItHelp
20 Feb 2009 22:26
Forum: DOS Batch Forum
Topic: FOR /R exclude ".svn" directory
Replies: 2
Views: 6182

Or without temp file:

Code: Select all

For /F "Delims=" %%A In ('"Dir * /aD/b/s|Find /V ".SVN" "') Do (
   Echo Directory Name is : %%A
)

:wink:
by DosItHelp
04 Feb 2009 22:24
Forum: DOS Batch Forum
Topic: Split directory name & filename from a string
Replies: 4
Views: 35115

RElliott63, FOR /F uses spaces as default delimiter. Empty the delimiter set using FOR /F "delim=" , i.e.: Set LookUpSet=Dir /b/s File1* File2* For /F "delim=" %%F In ('%LookUpSet%') DO ( Echo; Echo Path: %%~fF Echo File: %%~nxF Echo; Pause ) Let us know if it wor...
by DosItHelp
03 Feb 2009 22:08
Forum: DOS Batch Forum
Topic: Split directory name & filename from a string
Replies: 4
Views: 35115

santoshsri, Use a FOR loop like this: @echo off Set filename=C:\Documents and Settings\All Users\Desktop\Dostips.cmd For %%A in ("%filename%") do ( Set Folder=%%~dpA Set Name=%%~nxA ) echo.Folder is: %Folder% echo.Name is: %Name% Output will be: Folder is: C:\Documents and ...
by DosItHelp
26 Jan 2009 23:21
Forum: DOS Batch Forum
Topic: Extract rows from text file and slight reformatting
Replies: 10
Views: 13466

Or that way:

Code: Select all

setlocal ENABLEDELAYEDEXPANSION
for /l %%d in (1,1,30) do (
    set dd=0%%d
    set dd=!dd:~-2!
    echo !dd!
)

:D
by DosItHelp
26 Jan 2009 23:04
Forum: DOS Batch Forum
Topic: Trimming in a 'set' command via a variable
Replies: 2
Views: 6128

Dyno, There are two issues as far I can tell: 1. The value of the "trim" variable contains quotes that's why it will not substitute the string. To use quotes with the "SET" command to specify the value but without adding the quotes to the value use: set "trim=Microsoft "...
by DosItHelp
19 Jan 2009 21:00
Forum: DOS Batch Forum
Topic: extraction zip %1 in c:\windows\fonts doesn t work
Replies: 2
Views: 5675

Acris, Not sure, here is what you could try: Since the line with 7z.exe contains a exclamation character, it wouldn't work if DELAYEDEXPANSION is enabled. Try with "setlocal disabledelayedexpansion" @echo off setlocal disabledelayedexpansion set zip=%programfiles%\7-zip\ set "Fonts=%s...
by DosItHelp
17 Jan 2009 23:47
Forum: DOS Batch Forum
Topic: String count
Replies: 3
Views: 7498

spam_killer What error do you get? @Echo Off Setlocal Enableextensions set "str=many times during this day" call:strLen str len echo.string length is: %len% goto:eof rem Copy function below here :strLen string len -- returns the length of a string via binary search, maximum length 1023 :: ...
by DosItHelp
16 Jan 2009 01:41
Forum: DOS Batch Forum
Topic: Text files as input to batch command
Replies: 3
Views: 6722

rabbit123,

Use FOR loop:

Code: Select all

@echo off
for /f "tokens=*" %%A in (text.txt) do ECHO del %%A

Note, the "ECHO" is for testing.

DosItHelp? :wink:
by DosItHelp
16 Jan 2009 01:37
Forum: DOS Batch Forum
Topic: If statement problem
Replies: 1
Views: 4945

Cander,

I think you also need quotes around the "end".
Short:

Code: Select all

@echo off
Set /p connect=Type anything:
IF /i "%connect%"=="end" pause&goto:eof
echo %connect%
pause

right?
by DosItHelp
16 Jan 2009 01:30
Forum: DOS Batch Forum
Topic: [Resolved] delete duplicate mail in txt
Replies: 5
Views: 8451

Acris, Try this: @echo off Setlocal for /F "delims==" %%A in ('"set foundone[ 2>nul"') do set "%%A=" for /F %%A in (contacts.txt) do ( if not defined foundone[%%A] ( set "foundone[%%A]=Y" echo.%%A ) ) The first FOR loop removes ...
by DosItHelp
16 Jan 2009 01:04
Forum: DOS Batch Forum
Topic: Dir of .bat file in variable
Replies: 1
Views: 4774

chill, If for example your batch file is at c:\dostips\chill\mybatch.cmd then: set fullname=%~f0 set name=%~n0 set extension=%~x0 set drive=%~d0 set folder=%~p0 set driveAndFolder=%~dp0 will set the variables as follows: fullname will be: c:\dostips\chill\mybatch.cmd name will be mybatch extension w...
by DosItHelp
11 Jan 2009 21:32
Forum: DOS Batch Forum
Topic: SET command versus the cmd window input buffer
Replies: 3
Views: 10696

Re: SET command versus the cmd window input buffer

Gimson, ... namely to first set some variables to certain default values and then somehow allow the user to overwrite the ones he wants to ... ... that's the way to go. The behavior you observe is explained by two batch facts: 1. Variables changes within the batch are still visible when returning ba...