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:
Get Batch File Path Name Components
How to Get Batch File Path Name Components? I want to know the path name of the directory where the batch file is located.
✍: FYIcenter.com
To get different components of the batch file path name,
you can use batch parameter modifiers on %0, which
represents the batch file name.
Here is a batch file, Batch-File-Name.bat, that dumps the %0 parameter with different modifiers:
@echo off rem Batch-File-Name.bat - Show components of the batch file name echo 0 = %0 echo ~0 = %~0 echo ~f0 = %~f0 echo ~d0 = %~d0 echo ~p0 = %~p0 echo ~n0 = %~n0 echo ~x0 = %~x0 echo ~s0 = %~s0 echo ~a0 = %~a0 echo ~t0 = %~t0 echo ~z0 = %~z0 echo ~$PATH:0 = %~$PATH:0 echo ~dp0 = %~dp0 echo ~pd0 = %~pd0 echo ~nx0 = %~nx0 echo ~dp$PATH:0 = %~dp$PATH:0 echo ~ftza0 = %~ftza0
If you run the above batch file located at C:\fyicenter\Batch-File-Name.bat, you get the following output:
C:\fyicenter>Batch-File-Name.bat 0 = Batch-File-Name.bat ~0 = Batch-File-Name.bat ~f0 = C:\fyicenter\Batch-File-Name.bat ~d0 = C: ~p0 = \fyicenter\ ~n0 = Batch-File-Name ~x0 = .bat ~s0 = C:\FYICEN~1\BATCH-~2.BAT ~a0 = --a------ ~t0 = 11/22/2033 10:20 PM ~z0 = 552 ~$PATH:0 = C:\fyicenter\Batch-File-Name.bat ~dp0 = C:\fyicenter\ ~pd0 = C:\fyicenter\ ~nx0 = Batch-File-Name.bat ~dp$PATH:0 = C:\fyicenter\ ~ftza0 = --a------ 11/22/2033 10:20 PM 552 C:\fyicenter\Batch-File-Name.bat
⇒ Get Batch Parameter as File Path
2022-02-19, 5494👍, 0💬
Popular Posts:
How to remove YahooMessenger.exe from the startup application list to gain performance and reduce se...
How to add comments on slides? I am reviewing someone else's presentation and I want to add some com...
This tutorial shows you how to boost performance by stopping and disabling unnecessary services on W...
How to remove realsched.exe from the startup application list to gain performance and reduce securit...
Where to find tutorials on using Windows Vista computers? I want to learn how to use Windows Vista m...