Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...