Todd Vargo wrote:
> On 4/16/2016 10:43 AM, Tom Del Rosso wrote:
>> foxidrive wrote:
>>> On 12/04/2016 06:56, Saucer Man wrote:
>>>> I am trying to remove the day from %DATE%.
>>>>
>>>> SET MYDATE = %date%
>>>> SET MYDATE = %MYDATE:/=-%
>>>>
>>>> This will give me, for example, Sun 04-10-2016. How do I remove
>>>> the "Sun"? I want to keep the space in front of the 04.
>>>>
>>>
>>> Give this a crack:
>>>
>>> @echo off
>>> for %%a in (%MYDATE:/=-%) do set date2= %%a
>>
>> Does that have an advantage over this...
>>
>> SET MYDATE = %date:/=-%
>> SET MYDATE = %MYDATE:~3%
>
> The space following the variable name is significant and becomes part
> of the name. In the example above, the second SET command would clear
> the variable because the space is omitted in the name on the right
> side.
I copied the OP's lines and modified them. I didn't even notice the
spaces. If you noticed them you should warn the OP about it, because
it's another reason his original code wouldn't work.
> i.e. the second SET command should be...
>
> SET MYDATE = %MYDATE :~3%
I would say it should be this:
SET MYDATE=%MYDATE:~3%
I shouldn't have been too lazy to retype it, but I just did it again.
>> I find the FOR command is always slow.
>
> Slow in what way?
>
> Note, the FOR command iterates through a complete list. So if for
> example, you use it to search a long list and find what what you need
> early in the list, the FOR command still iterates through the entire
> list to the end.
>
> Other than that, can you provide an example where FOR is slow for you?
It's not just that it iterates the complete list. If you filter the
command output with FIND inside of FOR's parentheses, then the external
FIND command has to be loaded and it reads the complete output, and
passes a few lines to FOR. This runs faster in every script I've done
it.