When there is a complete file path, you can use the echo command to extract the file name.
The following code:
Echo off set a = "E: \ Program Files \ Image-Line \ FL Studio 9 \ FL.exe" set B = "E: \ Program Files \ Image-Line \ FL Studio 9 \ Plugins \ VST \ Revitar20 \ Effects \ GuitarRig \ GuitarRig-Revitar2Companion Bank. bnk "call: getname % a % call: getname % B % pause exit: getname echo % ~ Nx1 @ echo offset a = "E: \ Program Files \ Image-Line \ FL Studio 9 \ FL.exe" set B = "E: \ Program Files \ Image-Line \ FL Studio 9 \ Plugins \ VST \ Revitar20 \ Effects \ GuitarRig \ GuitarRig-Revitar2Companion Bank. bnk "call: getname % a % call: getname % B % pauseexit: getnameecho % ~ Nx1
Note echo % ~ 1 In nx1 refers to the first parameter that calls this label, that is, % a % in call: getname % a %.
You can directly use
Echo % ~ Nxa echo % ~ Nxa
You can use the following method to assign the command output to the variable.
For/f % I in ('command') do set var = % I