Categories:
Administration (10)
Adware Spyware (7)
Apache (10)
Bluetooth (125)
DOS Commands (1)
Edge (28)
General (2)
Internet Explorer (217)
Media Center (12)
Media Player (11)
Mozilla Firefox (18)
PHP (15)
Programming (8)
Security (4)
Silverlight (15)
Tips (17)
Tools (218)
Tutorials (5)
Windows 10 (166)
Windows 7 (636)
Windows 8 (1091)
Windows Phone (33)
Windows Server 2008 (165)
Windows Server 2012 (84)
Windows Server 2016 (23)
Windows Vista (52)
Collections:
Other Resources:
"for" Loop Parameter Modifiers
How to use "for" Loop Parameter Modifiers?
✍: FYIcenter.com
Here is a batch file, For-Loop-Parameter.bat, that
dumps the "for" loop parameter "%%p" with different modifiers:
@echo off rem For-Loop-Parameter.bat - Show components of a for loop parameter for %%p in (%1) do ( echo ---------------- echo p = %%p echo ~p = %%~p echo ~fp = %%~fp echo ~dp = %%~dp echo ~pp = %%~pp echo ~np = %%~np echo ~xp = %%~xp echo ~sp = %%~sp echo ~ap = %%~ap echo ~tp = %%~tp echo ~zp = %%~zp echo ~$PATH:p = %%~$PATH:p echo ~dpp = %%~dpp echo ~pdp = %%~pdp echo ~nxp = %%~nxp echo ~dp$PATH:p = %%~dp$PATH:p echo ~ftzap = %%~ftzap )
If you run the above batch file with a file name pattern, you get the following output:
C:\fyicenter>For-Loop-Parameter.bat *.log ---------------- p = error.log ~p = error.log ~fp = C:\fyicenter\error.log ~dp = C: ~pp = \fyicenter\ ~np = error ~xp = .log ~sp = C:\FYICEN~1\error.log ~ap = --a------ ~tp = 11/22/2033 10:46 PM ~zp = 16 ~$PATH:p = C:\fyicenter\error.log ~dpp = C:\fyicenter\ ~pdp = C:\fyicenter\ ~nxp = error.log ~dp$PATH:p = C:\fyicenter\ ~ftzap = --a------ 11/22/2033 10:46 PM 16 C:\fyicenter\error.log ---------------- p = ping.log ~p = ping.log ~fp = C:\fyicenter\ping.log ~dp = C: ~pp = \fyicenter\ ~np = ping ~xp = .log ~sp = C:\FYICEN~1\ping.log ~ap = --a------ ~tp = 11/22/2033 12:02 AM ~zp = 475 ~$PATH:p = C:\fyicenter\ping.log ~dpp = C:\fyicenter\ ~pdp = C:\fyicenter\ ~nxp = ping.log ~dp$PATH:p = C:\fyicenter\ ~ftzap = --a------ 11/22/2033 12:02 AM 475 C:\fyicenter\ping.log ---------------- ...
If you run the above batch file with a text message, the output is not that useful:
C:\fyicenter>For-Loop-Parameter.bat "Hello world!" ---------------- p = "Hello world!" ~p = Hello world! ~fp = C:\fyicenter\Hello world! ~dp = C: ~pp = \fyicenter\ ~np = Hello world! ~xp = ~sp = C:\FYICEN~1\Hello world! ~ap = ~tp = ~zp = ~$PATH:p = ~dpp = C:\fyicenter\ ~pdp = C:\fyicenter\ ~nxp = Hello world! ~dp$PATH:p = ~ftzap = C:\fyicenter\Hello world!
⇐ What Is "for" Loop Parameter
2022-02-04, 1658👍, 0💬
Popular Posts:
Can I remove startup application "DSAgnt.exe - Dell Support Agent" to speedup my computer and reduce...
What is "Net.Tcp Listener Adapter" in my Windows 7 service list? And how is "Net.Tcp Listener Adapte...
Can I remove startup application "issch.exe - InstallShield Update Service Scheduler" to speedup my ...
What is "SSDP Discovery" in my Windows 7 service list? And how is "SSDP Discovery" service related t...
What is "Lenovo Microphone Mute" in my Windows 7 service list? And how is "Lenovo Microphone Mute" s...