How can I test if a list of files exist?

后端 未结 6 1903
粉色の甜心
粉色の甜心 2021-02-15 18:38

I have a file that lists filenames, each on it\'s own line, and I want to test if each exists in a particular directory. For example, some sample lines of the file might be

6条回答
  •  心在旅途
    2021-02-15 19:11

    I wanted to add one small comment to most of the above solutions. They are not actually testing if a particular file exists or not. They are checking to see if the file exists and you have access to it. It's entirely possible for a file to exist in a directory you do not have permission to in which case you won't be able to view the file even though it exists.

提交回复
热议问题