Last active
January 29, 2023 17:05
-
-
Save C0nw0nk/0e48772d1f508dac1eb1de0d0df77559 to your computer and use it in GitHub Desktop.
remove last directory folder from variable batch file command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off & setLocal EnableDelayedExpansion | |
set root_path="%~dp0" | |
set "remove_last_folder=%root_path:"=%" | |
::remove last back slash | |
set "remove_last_folder=%remove_last_folder:~0,-1%" | |
::last folder into var | |
set "last1=%remove_last_folder:\=" & set "lastfolder1=%" | |
::remove last folder from var | |
echo its "!remove_last_folder:%lastfolder1%=!" | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment