Get full path and long file name from short file name

前端 未结 10 755
故里飘歌
故里飘歌 2020-12-15 09:13

I have an nice console file manager (eXtreme by Senh Liu), it passes short path/filenames as variables to a menu.bat.

How can I generate a full folder name + long fi

10条回答
  •  时光取名叫无心
    2020-12-15 09:47

    This returns the full long pathname, but depends on:
    A) there not being too many files in the tree (due to time taken)
    B) there is only one of the target (long) filename in the tree.

    @echo off
    for /f "delims=" %%a in (' dir /b "%~1" ') do set "file=%%a"
    for /f "delims=~" %%a in ("%~dp1") do cd /d "%%a*"
    for /f "delims=" %%a in ('dir /b /s /a-d "%file%" ') do set "var=%%a"
    echo "%var%"
    

    When called with mybat "d:\MYPROG~1\SHELLS\zBackup\REFSTO~1.BAL"
    it returned this:

    "d:\MyPrograms\SHELLS\zBackup\RefsToMyData.bal"

提交回复
热议问题