Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

Windows - Batch file ignoring multiple wildcards

I am trying to use a batch file to generate linux library symbolic links (Yes I'm trying to do this on windows, it needs to be cross platform). I have 3 files

  • libnum1.so.1.0
  • libnum2.so.1
  • libnum3.so

I am trying to loop through the files, and only generate links for the first 2 files (the 3rd file doesn't need a link generated). I am using the following command to loop through the files

for %%F in (lib*.so.*) do (
    echo %%F
)

However, instead of just grabbing the first 2 files, its also grabbing the 3rd file, which is breaking my script. How do I make the for loop ignore any file that ends in just .so?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
for %%F in (lib*.so.*) do IF /i "%%~xF" NEQ ".so" (

If the extension part of the filename is not equal to .so, regardless of case...

see for/?|more or `if/? from the prompt for docco


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...