Search found 3577 matches

by aGerman
26 Apr 2010 07:40
Forum: DOS Batch Forum
Topic: ** IF EXSIST ** Help
Replies: 1
Views: 2225

Re: ** IF EXSIST ** Help

You could try something like that: @echo off &setlocal set "Xpath=%systemroot%\system32\" set "Xname=shell32.dll" set "Xext=.old" :: check if the origin file exists if not exist "%Xpath%%Xname%" goto :EOF :: look for extension .old if not exist "%Xpat...
by aGerman
26 Apr 2010 05:25
Forum: DOS Batch Forum
Topic: execute script when firefox closes
Replies: 1
Views: 1637

Re: execute script when firefox closes

Think you would need two endless loops to watch for the running processes using the TASKLIST command. You could try this: @echo off :: *lets minimize the window @set "tmpVariable="||(set "tmpVariable=1"&start "%~dpnx0" /min cmd /c %0 %*&set "tmpVariable=&qu...
by aGerman
25 Apr 2010 08:32
Forum: DOS Batch Forum
Topic: Last logon
Replies: 1
Views: 1629

Re: Last logon

You could use a FOR /F loop. @echo off set /p "user=enter user: " for /f "delims=" %%a in ('net user %user%^|findstr /i /c:"last logon"') do set "lineLastLogon=%%a" :: your stuff here, eg.: echo %lineLastLogon% pause Regards aGerman
by aGerman
24 Apr 2010 18:14
Forum: DOS Batch Forum
Topic: Using a Variable to trim another variable?
Replies: 3
Views: 2462

Re: Using a Variable to trim another variable?

ian2000t wrote:[...]had to take off a % from each end[...]

Realy? That would never work for me, because the Call command expands %Length% to the value and removes one % from each end.

Regards
aGerman
by aGerman
24 Apr 2010 17:43
Forum: DOS Batch Forum
Topic: Using a Variable to trim another variable?
Replies: 3
Views: 2462

Re: Using a Variable to trim another variable?

You could try this:

Call Set BackupDir=%%BackupDir:~2,-%Length%%%

Regards
aGerman
by aGerman
30 Mar 2010 10:51
Forum: DOS Batch Forum
Topic: String to a batch command problem
Replies: 2
Views: 2067

Re: String to a batch command problem

Try to use quotes

Code: Select all

set /p "command=:"

if "%command%"=="" goto setcommand
%command%
if "%command%"=="cls" goto clear


Regards
aGerman
by aGerman
30 Mar 2010 10:48
Forum: DOS Batch Forum
Topic: replacing text
Replies: 4
Views: 3087

Re: replacing text

I don't understand why you want to use %0 to rename all .bat files. %0 contains the full name of the own file. How ever, to do it for its own name you have to use this line ren "%~0" "%~n0" otherwise (for all batches in a folder and sub folders) pushd "c:\your Folder" |...
by aGerman
28 Mar 2010 08:07
Forum: DOS Batch Forum
Topic: filter out / replace text string with blank text in text doc
Replies: 3
Views: 2708

Re: filter out / replace text string with blank text in text

Could work, but imho not a good idea to make a batch script for those intentions. You have to ascape all signs like ^, &, <, >, | and it will take a long time, because it would work like that: - for each line in ref.txt call a subroutine - for each line in needfilter.txt replace all special char...
by aGerman
28 Mar 2010 07:48
Forum: DOS Batch Forum
Topic: search & copy files from reference list in a text document
Replies: 2
Views: 1869

Re: search & copy files from reference list in a text docume

Untested: @echo off &setlocal for /f "usebackq delims=" %%a in ("ex. ref.txt") do set "fullname=%%a" &set "name=%%~nxa" &call :process pause goto :eof :process if not exist "%fullname%" ( >>"notexist.txt" echo "%fullname%&q...
by aGerman
28 Mar 2010 07:34
Forum: DOS Batch Forum
Topic: Need help renaming large amounts of files
Replies: 2
Views: 1694

Re: Need help renaming large amounts of files

You could try something like that: @echo off &setlocal for /f "delims=" %%a in ('dir /b /s^|findstr /c:"&"') do set "fullname=%%a" &set "name=%%~nxa" &call :process pause goto :eof :process set "newname=%name:&=and%" ren "%fu...
by aGerman
26 Mar 2010 15:11
Forum: DOS Batch Forum
Topic: trouble with setlocal
Replies: 2
Views: 1717

Re: trouble with setlocal

Imho the endlocal command should not be the problem. Because of this statement: this is what I have for a search function to grab the path of the file I input. I speculate that you change the "path" environment variable somewhere and thats why the the commands can't be found. Have a look t...
by aGerman
25 Mar 2010 14:34
Forum: DOS Batch Forum
Topic: Batch file doesn't process parameter
Replies: 6
Views: 3747

Re: Batch file doesn't process parameter

Well, I'm sure that you know parameters like %1, %2 etc. %0 is a special kind of parameter and contains the "own call" of the batch file (means something like the full name). You can use options for this parameters, so the d is for drive and the p is for path. All in all %~dp0 returns driv...
by aGerman
25 Mar 2010 13:13
Forum: DOS Batch Forum
Topic: Batch file doesn't process parameter
Replies: 6
Views: 3747

Re: Batch file doesn't process parameter

You're welcome.
For your understanding:
The dot (.\) is only relative to your batch file, but not to msaccess.exe. It needs the entire path.
Because /cmd is a switch of msaccess.exe you can't use it only with the .mdb file.

Grüße aus Thüringen nach Baden-Württemberg :wink:
by aGerman
25 Mar 2010 12:58
Forum: DOS Batch Forum
Topic: Starting and Stopping Services in Windows
Replies: 6
Views: 5132

Re: Starting and Stopping Services in Windows

Hmm OK. I had a look to the help of sc. The option qc returns informations about a service. I tried it with the BROWSER service: @echo off &setlocal for /f "tokens=2* delims=: " %%a in ('sc qc BROWSER ^|findstr /i /c:"START_TYPE"') do set "STypeNumber=%%a" &set ...
by aGerman
25 Mar 2010 12:08
Forum: DOS Batch Forum
Topic: Batch script to move, rename files.?
Replies: 5
Views: 3821

Re: Batch script to move, rename files.?

Maybe something like that: @echo off &setlocal set "filename=Face_0001.jpg" set "source=D:\Animation\Temp1" set "dest_default=D:\Animation\Folder1" call :process1 set "source=D:\Animation\Temp2" set "dest_default=D:\Animation\Folder2" call :proce...