0

I have string in batch file and I want only last part or after specific keyword. My code is :

@ECHO OFF
Set path =%~dp0
echo %path %
PAUSE

Suppose the Path is c:\x\y\z\

How can I extract only z or string(s) after y.

  • Don't use `path` as var name not even with a trailing space. `for %%a in ("%~dp0.") Do Set "Parent=%%~nxa"` –  Aug 16 '17 at 14:47
  • https://stackoverflow.com/questions/15567809/batch-extract-path-and-filename-from-a-variable/15568164#15568164 - simply treat the pathname as a filename. Batch `set` is sensitive to spaces on both sides of the `=`. You would be setting a variable named `path ` not `path` - which is a reserved variablename (contains a list of directories to be searched for an executable if not found in the current directory.) – Magoo Aug 16 '17 at 17:19
  • Found Solution on Link : https://stackoverflow.com/q/17279114/6554592 Thanks for Help – Lokesh Chinchkhedkar Aug 17 '17 at 11:59

0 Answers0