-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathread_files_in_folder.py
More file actions
36 lines (26 loc) · 1010 Bytes
/
read_files_in_folder.py
File metadata and controls
36 lines (26 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import sys
import stat
def read_files_in_folder(input_directory):
"""
Read_files_in_folder
Get the complete list of good excluding hidden Files, excluding any subfolders in the input folder
INPUT FORMAT
--------------------------
(InputDirectory)
OUTPUT FORMAT
--------------------------
[fileList, file_list_length]
--------------------------
-- National Center for Microscopy and Imaging Research, NCMIR
-- Matthias Haberl -- San Diego, 02/2016"""
fileList = [file_name for file_name in os.listdir(input_directory)
if not os.path.isdir(file_name) and not file_name.startswith('.')]
if sys.platform.startswith("win"):
fileList = [
file_name for file_name in fileList if not bool(
os.stat(
os.path.join(
input_directory,
file_name)).st_file_attributes & stat.FILE_ATTRIBUTE_HIDDEN)]
return [sorted(fileList), len(fileList)]