Search found 1041 matches

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

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

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"...
by jeb
29 May 2008 13:56
Forum: DOS Batch Forum
Topic: script to rename file based on a string in the first line
Replies: 1
Views: 5917

Hi Ikea,

take a look at the for /f "tokens=..." command, that should do the work for you.

jeb
by jeb
29 May 2008 13:42
Forum: DOS Batch Forum
Topic: Any one-liner script to determine leap year?
Replies: 4
Views: 11516

Hi Frank,

the 'set' command supports '&' "bitwise and", "| bitwise or"
but the & is also the delimeter for the next command on one line.

like

Code: Select all

set /a var=1 & echo hello


same for the pipe '|'

therefore you need to escape them with '^'

jeb
by jeb
25 May 2008 15:36
Forum: DOS Batch Forum
Topic: map and lookup - please explain
Replies: 2
Views: 7296

Hi Frank, Bu what is the reason for 'CALL'? What will be different if withou using CALL? Why '&rem.'? 1. Difference between "Call Set" and "Set" CALL SET v=%%map:*%v%-=%% the call results in a double expansion of the line. The first expansion results in (with v=sat) v=%map:*s...
by jeb
25 May 2008 15:10
Forum: DOS Batch Forum
Topic: Any one-liner script to determine leap year?
Replies: 4
Views: 11516

Hi Frank,

in a batchfile this is a solution for the years from 1901-2099

Code: Select all

set /a leapyear=! (%year% %% 4 )


obviously :wink: this is the full solution

Code: Select all

set /a leapyear=((!(%year%%%400))^|!(!(%year%%%100)))^&!(%year%%%4)


jeb
by jeb
25 May 2008 06:16
Forum: DOS Batch Forum
Topic: Batch routine to change file names
Replies: 2
Views: 7478

Hi Nelson, begin with this @echo off setlocal enableextensions setlocal enabledelayedexpansion set srcPath=c:\temp\hund set prefix=LLL- echo %prefix% for %%a in (%srcPath%\*.*) do ( set oldName=%%~nxa set newName=%%~dpa%prefix%!oldName:~1! echo ren !oldName! !newName! ) jeb
by jeb
23 May 2008 11:41
Forum: DOS Batch Forum
Topic: Elementary file rename problem.
Replies: 1
Views: 5730

Hi,

I suppose you can't solve it with xcopy or copy,
but try this

Code: Select all

@echo off
setlocal

set srcPath=c:\temp\hund
set prefix=100
echo %prefix%

for %%a in (%srcPath%\*.*) do echo ren %%a %%~dpa%prefix%%%~nxa


jeb
by jeb
12 May 2008 15:56
Forum: DOS Batch Forum
Topic: Batch file for mp3 encoding
Replies: 2
Views: 7203

Hi,

Code: Select all

for %%a in (*.wav) DO lame.exe /myoptions %%a %%~na.mp3


should work.

The trick is %%~n which results in the filename (without) extension.

jeb
by jeb
12 May 2008 15:36
Forum: DOS Batch Forum
Topic: Make a script independent of the System drive letter
Replies: 1
Views: 5615

Hi Budhax, Is this method enough and safe to make the script independent of the "System drive letter"? yes and no. yes it is enough to independent of the drive letter. but it's useless because "Program Files" is not static, on my XP System it's called "Programme". If yo...
by jeb
07 May 2008 16:08
Forum: DOS Batch Forum
Topic: To save RTF in plain txt File Format
Replies: 2
Views: 6692

Hi,

I suppose, I understand your problem, but it is a problem.

You can either try to solve it complete with a batch file.
Reading each line and parse it - I assume it is a bad idea

or you can write a dot net program that solves it, this should be simple.

Only my suggestions :?
jeb
by jeb
06 May 2008 05:44
Forum: DOS Batch Forum
Topic: passing and gaining parameters to MS DOS Batch file
Replies: 8
Views: 14755

Hi, try this as an idea ::::::::::::::::::::::::::::::::::::::::::::::::: :loadFile <filename> <resultVar> :: Loads the content of a file into an array an set the length of the array :: without setlocal, because the array should be visible outside of this function set loadFile.counter=0 for /f "...
by jeb
04 May 2008 14:09
Forum: DOS Batch Forum
Topic: passing and gaining parameters to MS DOS Batch file
Replies: 8
Views: 14755

Hi jaffamuffin,

I tested it now with 2644 files (Windows\System32), with no problems (only echo the filenames).
I'm using Vista yet, but on XP I use a similiar batch with more than 100 files.

Your break at 30 files seems to be another problem.

jeb
by jeb
23 Apr 2008 16:04
Forum: DOS Batch Forum
Topic: Searching for file owners, but struggling with space in name
Replies: 2
Views: 6815

Hi, the for loop is the main problem the default delimiter is a space, so you got in %%i only the first part. Quotes dont help there. First you need to get the full line with "tokens=*" Then you have to get the correct directory with "%%i" ex. "Program Files" else you g...
by jeb
23 Apr 2008 15:51
Forum: DOS Batch Forum
Topic: Testing if folder exist when there are spaces in a path
Replies: 3
Views: 8110

Sorry I does not read and does not test it but now ... @echo off setlocal set INIT_DIR=%~1 call :checkIt result "%INIT_DIR%" echo result=%result% goto :eof :::::::::::::::::::::::::::: :checkIt setlocal set p=%~a2 ( endlocal if "%p:~0,1%" == "d" ( set %~1=1 )...