Batch Extract path and filename from a variable

前端 未结 5 1580
故里飘歌
故里飘歌 2020-11-27 11:18

How can I extract path and filename from a variable?

Setlocal EnableDelayedExpansion
set file=C:\\Users\\l72rugschiri\\Desktop\\fs.cfg

I wa

5条回答
  •  我在风中等你
    2020-11-27 12:10

    if you want infos from the actual running batchfile, try this :

    @echo off
    set myNameFull=%0
    echo myNameFull     %myNameFull%
    set myNameShort=%~n0
    echo myNameShort    %myNameShort%
    set myNameLong=%~nx0
    echo myNameLong     %myNameLong%
    set myPath=%~dp0
    echo myPath         %myPath%
    set myLogfileWpath=%myPath%%myNameShort%.log
    echo myLogfileWpath %myLogfileWpath%
    

    more samples? C:> HELP CALL

    %0 = parameter 0 = batchfile %1 = parameter 1 - 1st par. passed to batchfile... so you can try that stuff (e.g. "~dp") between 1st (e.g. "%") and last (e.g. "1") also for parameters

提交回复
热议问题