Obtain the file name through string truncation during batch processing.

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.