Search found 967 matches

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

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 )...
by jeb
21 Apr 2008 15:12
Forum: DOS Batch Forum
Topic: Testing if folder exist when there are spaces in a path
Replies: 3
Views: 5550

Hi honyk, there are missing the " in the first line. try if exist "%INIT_DIR%Images\nul" ( mkdir "%OUT_DIR%Images" xcopy /y "%INIT_DIR%Images" "%OUT_DIR%Images" >> %LOG% 2>&1 if ERRORLEVEL 1 ( GOTO ERROR ) ) jeb
by jeb
20 Apr 2008 15:57
Forum: DOS Batch Forum
Topic: Replace space in variable with %20
Replies: 3
Views: 11100

Hi, I suppose you are right, it seems impossible to replace by percent this way. But you can choose another way, an easy if you want to replace only spaces is ... @echo off setlocal enabledelayedexpansion set myPath="program files are here" call :replace %myPath% echo %result% goto :eof ::...
by jeb
20 Apr 2008 14:36
Forum: DOS Batch Forum
Topic: Help with IF NOT Problem
Replies: 3
Views: 5381

Hi,

yes it should work, I tested it on my system with some testfiles.

But you should add after the "pause" a
"goto :eof"

else the ":skip" and the ":skip2" part are always run after the pause

jeb
by jeb
18 Apr 2008 07:03
Forum: DOS Batch Forum
Topic: Help with IF NOT Problem
Replies: 3
Views: 5381

Hi cwsterling, nice error you found. Your porblem is, you want to use goto and jump-marks inside a for loop. That's not allowed. for /f "delims==" %%D in ('dir /s /b "!filename!"') do ( :xy ) results in an error You build up a double error, therefore you got no er...
by jeb
18 Apr 2008 06:28
Forum: DOS Batch Forum
Topic: [unsolved] how2 expand replaceable character variables ?
Replies: 1
Views: 4144

Hi chrizoo,

in my opinion it is not possible to expand this type of variables.
But obviously you can copy them and then do the job.

SET aa=%%a
echo %aa:~0,5%

jeb
by jeb
12 Feb 2008 02:51
Forum: DOS Batch Forum
Topic: set command behavior and auto creating path
Replies: 6
Views: 7486

Split path

Hi,

reference at FOR /?

splitPath.bat

Code: Select all

echo Path=%~dp1
echo filename=%~nx1


Use it like

Code: Select all

splitPath "c:\tmp\tmp1 add\file 22.exxt"


Jan Erik
by jeb
06 Feb 2008 15:29
Forum: DOS Batch Forum
Topic: How do I specify the " character as a delimiter in FOR
Replies: 2
Views: 4626

Hi melliott, I can see your problem, but can't solve it a "nice" way, but I can solve it in two steps. First reading a complete line, then replacing all " to another "unsued" character (I use #), then splitting it with another FOR /F. @echo off SETLOCAL ENABLEDELAYEDEXPANSIO...
by jeb
06 Feb 2008 05:50
Forum: DOS Batch Forum
Topic: set command behavior and auto creating path
Replies: 6
Views: 7486

Hi Macarong, Btw, does anyone has a code to create a path in case of the path input does not exist? I suppose you want to create a path "c:\temp\myPath\mySrc" if it is not exists. you can simple use md \temp\myPath\mySrc if the path, it will result with an error, but that can be ignored. J...
by jeb
01 Feb 2008 02:22
Forum: DOS Batch Forum
Topic: passing and gaining parameters to MS DOS Batch file
Replies: 8
Views: 9754

Hi Abo, a solution with use of array lists. Loads first the filenames in to an array picList[0]=image001.jpg picList[1]=image002.jpg picList[2]=image003.jpg then it replace the name with "master" or "attach". @echo off SETLOCAL ENABLEEXTENSIONS SETLOCAL ENABLEDELAYEDEXPANSION dir...
by jeb
31 Jan 2008 03:24
Forum: DOS Batch Forum
Topic: passing and gaining parameters to MS DOS Batch file
Replies: 8
Views: 9754

Hi, i have unKnown number of images.jpg i need MS DOS Batch file to Group them in One New file What are the names of the files and what to do with them? My understanding of the behavior is: The batch file collect all img*.jpg files and put them in to a list, then the batch file starts to rename all ...
by jeb
31 Jan 2008 03:08
Forum: DOS Batch Forum
Topic: [solved] if A or B
Replies: 4
Views: 6872

Ok, I prefer functions instead of too much inline code. So here my simple solution. The good think about it: The number of OR conditions is not limited, just add a compare statement. @echo off SETLOCAL ENABLEEXTENSIONS SETLOCAL ENABLEDELAYEDEXPANSION for /L %%N in (1,1,6) do ( call :logi...
by jeb
10 Jan 2008 07:38
Forum: DOS Batch Forum
Topic: Can I calculate a date?
Replies: 8
Views: 13239

A little bit faster

Hi, your solution set /a "yy=10000%yy%, mm=10000%mm%, dd=10000%dd%" set /a "yy=1%yy:~-4%-10000,mm=1%mm:~-2%-100,dd=1%dd:~-2%-100" My suggestion could build with one line, more compact and faster. Tested on my system 40000 times, it is two times faster, 8 instead of 16seconds. set...
by jeb
21 Nov 2007 14:51
Forum: DOS Batch Forum
Topic: directory command output
Replies: 3
Views: 5836

Hi Hank, I changed :checkForModifications a bit and adding some comments, it should work for it. @echo off SETLOCAL ENABLEDELAYEDEXPANSION REM **** Format "YYYYMMDD" set dateTime=20070719 rem *** Iterate through all directories FOR /f "tokens=*" %%a IN ('dir /b /o:n /a:d /t:w...
by jeb
20 Nov 2007 02:59
Forum: DOS Batch Forum
Topic: directory command output
Replies: 3
Views: 5836

Hi Hank, 2 - How do I eliminate folders from the list that end with a specific character? Look at :checkForValidName, first I copy the first parameter to a local var. And on the local var I use the string manipulation function %var:~-3% (not possible on a parameter like %1). 3 - How do I add the com...