Search found 18 matches
- 06 Oct 2015 12:00
- Forum: DOS Batch Forum
- Topic: For Loop, multiple files/variables. Current file/variable
- Replies: 9
- Views: 7141
Re: For Loop, multiple files/variables. Current file/variab
Although it is possible to do it that way, the question is why do it that way ? The code I posted was just a snippet. In reality it's many more lines, so I'd have to repeat the same code in each for...loop. I suppose I could put the duplicate code in a function, if that's the right word in Windows ...
- 06 Oct 2015 11:57
- Forum: DOS Batch Forum
- Topic: For Loop, multiple files/variables. Current file/variable
- Replies: 9
- Views: 7141
- 06 Oct 2015 09:28
- Forum: DOS Batch Forum
- Topic: For Loop, multiple files/variables. Current file/variable
- Replies: 9
- Views: 7141
Re: For Loop, multiple files/variables. Current file/variab
Thanks Antonio, that's how I originally had it (in fact is was 3 separate for loops for the different variables. I was convinced you could do it on one, and I think I've worked out a way. Basically set a variable which contains the other 3 variable names, and do an 'outer' loop on the new variable: ...
- 06 Oct 2015 05:17
- Forum: DOS Batch Forum
- Topic: For Loop, multiple files/variables. Current file/variable
- Replies: 9
- Views: 7141
Re: For Loop, multiple files/variables. Current file/variab
Hi, The current variable it is on. Basically I need to do something like this: for %%x in (%args% %defargsfile% %userargs%) do ( set currentvar=XXX for /f "tokens=1,* delims=-:" %%g in (%%x) do ( if <currentvar> equ %args% ( call :setarg "define" "%%g" "%%~h" ...
- 06 Oct 2015 04:22
- Forum: DOS Batch Forum
- Topic: For Loop, multiple files/variables. Current file/variable
- Replies: 9
- Views: 7141
For Loop, multiple files/variables. Current file/variable
Hey, With a loop like this, is it possible to know which file or variable it's currently looping through? for %%x in (%args% %defargsfile% %userargs%) do ( for /f "tokens=1,* delims=-:" %%g in (%%x) do ( call :setarg "%%g" "%%~h" echo.Current variable is: xxx ) ) So kno...
- 02 Oct 2015 06:16
- Forum: DOS Batch Forum
- Topic: IF: [ ] vs " "
- Replies: 9
- Views: 5809
Re: IF: [ ] vs " "
Like an absolute boss!
Thanks
Thanks
- 01 Oct 2015 13:48
- Forum: DOS Batch Forum
- Topic: IF: [ ] vs " "
- Replies: 9
- Views: 5809
Re: IF: [ ] vs " "
If I was explicitly using %1 %2 they'd always have to be in the same position. Well I disagree with that. This is what I'm currently doing: for %%x in (%*) do ( set arg=%%~x set /a a_count+=1 if /i [!arg:~0^,2!] equ [/d] ( if [!arg:~3!] neq [] for /f "delims=" %%x in (!arg:~3!) do set &qu...
- 01 Oct 2015 04:12
- Forum: DOS Batch Forum
- Topic: Using double quotes when setting variables
- Replies: 1
- Views: 1905
Using double quotes when setting variables
Is there a best practice as to when variables should be enclosed like set "var=val"
Is it the case that if val contains spaces, enclose it, unless it's using a delayed expansion value:
set "var1=Hello world"
set var2=!var!
?
Is it the case that if val contains spaces, enclose it, unless it's using a delayed expansion value:
set "var1=Hello world"
set var2=!var!
?
- 29 Sep 2015 02:53
- Forum: DOS Batch Forum
- Topic: Multiple string manipulation in one go
- Replies: 2
- Views: 2422
Re: Multiple string manipulation in one go
Because %%~dpx expands to the path including the trailing backslash, which I don't need.
- 29 Sep 2015 02:52
- Forum: DOS Batch Forum
- Topic: IF: [ ] vs " "
- Replies: 9
- Views: 5809
Re: IF: [ ] vs " "
I wanted to allow different positions for the arguments.
If I was explicitly using %1 %2 they'd always have to be in the same position.
So command.cmd /t /s /v would behave differently to command.cmd /s /v /t as the argument values would change.
If I was explicitly using %1 %2 they'd always have to be in the same position.
So command.cmd /t /s /v would behave differently to command.cmd /s /v /t as the argument values would change.
- 28 Sep 2015 15:35
- Forum: DOS Batch Forum
- Topic: Multiple string manipulation in one go
- Replies: 2
- Views: 2422
Multiple string manipulation in one go
Hey,
Is it possible to do this in the one SET:
I can't quite get the combo right: %%~dp0,-1 for example.
Is it possible to do this in the one SET:
Code: Select all
for /f "tokens=1* delims=" %%x in ('dir /b /s "%SystemDrive%\mkvtoolnix*.exe"') do set toolsdir=%%~dpx
set toolsdir=!toolsdir:~0,-1!
I can't quite get the combo right: %%~dp0,-1 for example.
- 28 Sep 2015 15:32
- Forum: DOS Batch Forum
- Topic: IF: [ ] vs " "
- Replies: 9
- Views: 5809
Re: IF: [ ] vs " "
Not necessarily validate them, as such, but break them up. So someone can enter /T:<path>, hence grabbing the first 2 chars, so I check for /T then take the rest of the string as another value, so <path>: REM Check for arguments for %%x in (%*) do ( set arg=%%x if /i [!arg!] equ [/l] ( set logtofile...
- 28 Sep 2015 10:03
- Forum: DOS Batch Forum
- Topic: IF: [ ] vs " "
- Replies: 9
- Views: 5809
IF: [ ] vs " "
Hey, Why does this work: if /i "!arg:~0,2!"=="/t" ( rem Do this... ) but this doesn't: if /i [!arg:~0,2!] equ [/t] ( rem Do this... ) It results in: 2!] was unexpected at this time. Square brackets work fine for other manipulation though: if [!arg:~2!] equ [/t]... If I escape the...
- 26 Sep 2015 16:17
- Forum: DOS Batch Forum
- Topic: For Loop.. delims
- Replies: 8
- Views: 5257
Re: For Loop.. delims
foxidrive wrote:Basically the output from mkvinfo is this:Code: Select all
| + Title: Jellyfish-3-Mbps: Copy (2)
Plus, some files may contain multiple colons
What do you see when there are multiple colons?
In this case it would be just 'Jellyfish-3-Mbps', so between the 2 colons.
- 26 Sep 2015 16:16
- Forum: DOS Batch Forum
- Topic: For Loop.. delims
- Replies: 8
- Views: 5257
Re: For Loop.. delims
ShadowThief wrote:Also, it's worth noting that file names in Windows cannot include colons, so unless you're pulling these from a Linux machine, you really have nothing to worry about there.
Yeah, sorry. I didn't mean in the filename. Title is a meta data property of MKV files.