Search found 923 matches

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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