The parent folder of a Batch is in the Variable %~dp0
located. Example:
@echo off&setlocal
for %%i in ("%~dp0.") do set "folder=%%~fi"
echo %folder%
More Related Contents:
- How to delete files/subfolders in a specific directory at the command prompt in Windows
- How to list all folder with size via batch file
- Batch create folders based on part of file name and move files into that folder
- How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?
- Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files
- How do you get the string length in a batch file?
- How do you loop through each line in a text file using a windows batch file?
- How do I escape ampersands in batch files?
- How to use random in BATCH script?
- Batch script: how to check for admin rights
- Why does %date% produce a different result in batch file executed as scheduled task?
- Setting a system environment variable from a Windows batch file?
- In Windows cmd, how do I prompt for user input and use the result in another command?
- Batch script loop
- FORFILES date -after- (date calc in cmd file)
- Create an empty file on the commandline in windows (like the linux touch command)
- What is the proper way to test if a parameter is empty in a batch file?
- In Windows: How do you programatically launch a process in administrator mode under another user context?
- How do I shutdown, restart, or log off Windows via a bat file?
- How do I create a shortcut via command-line in Windows?
- Why “The system cannot find the batch label specified” is thrown even if label exists?
- Batch script with for loop and pipe
- How to rename file by replacing substring using batch in Windows [closed]
- How to pass environment variables as parameters by reference to another batch file?
- Text garble in batch script for wmic command
- How do I increment a folder name using Windows batch?
- How to append a date in batch files
- Windows Batch file to echo a specific line number
- How to expand a CMD shell variable twice (recursively)
- Split %date% in a batch file regardless of Regional Settings