VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or buy Replay Video Capture or PlayON and record Netflix, HBO, etc! :)
+ Reply to Thread
Results 1 to 3 of 3
Thread
  1. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    This probably an easy question but I cannot find the answer. I recently found several loacations,where the batch file uses an unusual (to me) variable form.

    The most recent is supposed to remove leadingbzeros from a variable. Can anyone explain what the following means?

    Set n=000234765
    Set n=%n:0=% <---- what is this and what does it do and how?

    I know the common form of !n:~0,6! And similar but can find no explanation of n=%n:0=%
    Thanks
    Quote Quote  
  2. By experimentation, it replaces all occurrences of the character sequence to the left of the = with the character sequence to the right of the = In this case all zeros are replaced with nothing. In the following the first "02" is replaced with "__"

    Code:
    Set n=000234765
    
    echo %n%
    
    Set n=%n:02=__%
    
    echo %n%
    
    pause
    Last edited by jagabo; 21st May 2018 at 21:17.
    Quote Quote  
  3. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    @jagabo. Thank you much. I needed to replace zeros but couldn't for the life of me figure out how it worked or find reference to it except in the example i found. Thanks again.

    Update. Once you let me know it 'replaces characters i went searching again and found a reference in case anyone reads and needs this in the future. Thanks again jagabo. Master of video as well as programming! Lol
    https://ss64.com/nt/syntax-replace.html
    Last edited by Budman1; 21st May 2018 at 21:41.
    Quote Quote  



Similar Threads