Force passing long file names to dos for command
I have problem with following simple dos command:
FOR %%f IN (.\07_PROCEDURES\DataSources\*.sql) DO echo "%%f"
It does some action for every file with sql
extension. Everything works fine, except long names. When directory contains fi开发者_运维问答les, with sql_
extensions, they are picked up too. But this behavior depend on whether 8.3 files are turned on or off on file system. If they are turned on (default choice on most computers) sql_
are passed, because extension is cropped.
How to force for
fetch long file names ? Thanks !
P.S. Do not offer powershell upgrade.
You can try to examine the extension in the loop itself
for %%f in (*.sql) do (
if /i "%%~xf" EQU ".sql" echo %%f
)
You can try something like this:
for /f "usebackq delims=" %%f in (`dir /b .\*.sql ^| findstr /r .*\.sql$`) do @echo "%%f"
精彩评论