开发者

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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜