-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlistfiles.py
More file actions
executable file
·37 lines (29 loc) · 849 Bytes
/
Copy pathlistfiles.py
File metadata and controls
executable file
·37 lines (29 loc) · 849 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
37
#!/usr/bin/python -tt
"""list all files in a given directory. Listing shows absolute path of files
Usage: listfiles /path/directory"""
__author__ = "Daniel T."
__license__ = "GPL"
__version__ = "0.1.0"
__maintainer__ = "danasmera"
__email__ = "daniel@danasmera.com"
import os
import sys
import signal
if len(sys.argv) > 1:
mypath = sys.argv[1]
else:
mypath = os.getcwd()
def main():
""" main function """
try:
if os.path.exists(mypath) and os.path.isdir(mypath):
for dp, dn, fn in os.walk(mypath):
for myfile in fn:
print os.path.join(dp, myfile)
else:
print "mypath not found or not a directory!"
except KeyboardInterrupt:
print("Interrupt key pressed, aborting.")
sys.exit(0)
if __name__ == "__main__":
sys.exit(main())