-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathls.py
More file actions
27 lines (21 loc) · 658 Bytes
/
Copy pathls.py
File metadata and controls
27 lines (21 loc) · 658 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
#!/usr/bin/env python
from __future__ import print_function
import os,sys
path = '.'
if len(sys.argv) == 2:
path = sys.argv[1]
files = os.listdir(path)
for name in files:
print(name)
full_path = os.path.join(path, name)
print(full_path)
inode = os.stat(full_path)
print(' ' + str(inode.st_size))
print(' ' + str(inode.st_mode))
print(' ' + ('f' if inode.st_mode & 0100000 else '-' ))
print(' ' + ('d' if inode.st_mode & 0040000 else '-' ))
if os.path.isdir(full_path):
print(' dir')
elif os.path.isfile(full_path):
print(' file')
print(' ' + str(os.path.getsize(full_path)))