Download pairPapers/countAllFiles.py from ArnoLiu/MOF: direct link, hf CLI and curl.
- Browser
- Download file 459 Bytes
-
https://huggingface.co/ArnoLiu/MOF/resolve/main/pairPapers/countAllFiles.py
- Command line
-
hf download hf://ArnoLiu/MOF/pairPapers/countAllFiles.py
-
curl -L -o countAllFiles.py https://huggingface.co/ArnoLiu/MOF/resolve/main/pairPapers/countAllFiles.py
459 Bytes
| import os | |
| def count_files_in_directory(directory): | |
| file_count = 0 | |
| # 遍历目录及其子目录 | |
| for root, dirs, files in os.walk(directory): | |
| # 统计当前目录中的文件数量 | |
| file_count += len(files) | |
| return file_count | |
| # 获取当前工作目录 | |
| current_directory = os.getcwd() | |
| # 计数文件 | |
| total_files = count_files_in_directory(current_directory) | |
| print("当前目录及子目录中的文件总数为:", total_files) | |