Windows 10: do we still have %~ in batch files in windows 10

  1.    28 Feb 2017 #1

    do we still have %~ in batch files in windows 10


    Greetings
    I still write batch files like I always did since dos.
    In windows XP all kinds of %~ variables were added to the vocabulary.
    Do we still have those or were they replaced by other in windows 10?
    where do I find a list of batch file commands still used in windows 10?
    thank you
      My ComputerSystem Spec

  2.   My ComputersSystem Spec


  3. Posts : 93
    Windows 10
       28 Feb 2017 #3

    Hi,

    zivshosh said: View Post
    In windows XP all kinds of %~ variables were added to the vocabulary.
    Do we still have those or were they replaced by other in windows 10?
    That syntax resembles either argument expansion or expansion of dynamic variables from the For loop. The way youíve phrased your question though, ďwere added to the vocabularyĒ, makes it sound like itís a variable in itself but itís more of a syntactic feature primarily used to strip quotes from dynamic variables. ď%~Ē has an extended meaning in a for loop however (see Breeís answer). The command processor hasnít been updated in years, but I canít verify for you if ď%~Ē had existed back then.

    zivshosh said: View Post
    where do I find a list of batch file commands still used in windows 10?
    Typically in a shell language you donít get the luxury of knowing what commands are available for use. You just have to know that a particular command exists to be able to use it. There are a couple of command lists online though. SS64, which Iíve linked to in this post twice already, has a really good one. Their documentation is actively kept up to date as well.
    Last edited by Pyprohly; 28 Feb 2017 at 08:51. Reason: Fixed awkward wording
      My ComputerSystem Spec


  4. Posts : 601
    Windows 10 Home x64 Version 1803 (OS Build 17134.48)
       28 Feb 2017 #4

    This isn't my thread, but thanks for that link anyway.
      My ComputersSystem Spec


  5. Posts : 6,966
    10 Home x64 (1803) (10 Pro on 2nd pc)
       28 Feb 2017 #5

    Pyprohly said: View Post
    ...the command processor hasnít been touched much in years although I canít verify if ď%~Ē syntax existed back then.
    %~ is interesting, and proves there's always more to learn (well, it's new to me) and, yes, they work in Win10.

    Windows NT 4 introduced a set of new features for command line parameters...
    ...
    %~fn will return the fully qualified path of %n if %n is a valid file name or directory
    Batch files - Command line parameters

    The variables %0, %1, %2, %3, .... %9 have existed since DOS. They are the arguments used to call the batch file, %0 being the name of the batch file itself. For example, save the following as Tell_Me.bat then run it with a few parameters.

    Code:
    @echo off
    echo You called %~f0 with arguments %1, %2 and %3
    To use a FOR ... DO loop in a batch file you have to escape the '%' character by typing it twice, for example:
    Code:
    @echo off
    for %%X in (1,2,3,4,5) do echo %%X

    For a shell language, typically you donít get to know what command are available for use. You must know that a command exists to be able to use it. There are a couple of lists online though, like SS64, which Iíve linked in this post twice already, itís a really good one.
    This is the most recent A-Z list I know of on TechNet.
    Updated: November 23, 2015
    Applies To: Windows Server 2003, Windows Vista, Windows XP, Windows Server 2008, Windows 7, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2000, Windows Server 2012, Windows 8
    https://technet.microsoft.com/en-us/...(v=ws.11).aspx
    Last edited by Bree; 28 Feb 2017 at 08:22.
      My ComputersSystem Spec


 

Related Threads
I'm not sure if this is posted in the right section. gHacks - Improve Windows 10 with one-click batch files
Hi, I think I used to do this all the time but that was a long time ago. I want to open a Wordperfect (WP) document then run an executable program, the WP file opens fine but the executable won't run until I close the WP file. Any clues? ...
I use Photoshop for .jpg files, but it can't seem to do .png. What programs can do this?
Somehow (most likely my fault) .bat files have defaulted to opening my text editor (UltraEdit) instead of executing. I took all the file associations out of UltraEdit and re-started - no change I followed internet advice to remove ...
Batch Rename Deletes Files in Performance & Maintenance
Hey all, I just upgraded to Windows 10 last night, and I've been playing around with the new File Explorer. One thing I tried was the batch rename function (by which I mean just selecting multiple files and clicking "rename"). I quickly realized...
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:42.
Find Us