36 lines
1,015 B
Python
36 lines
1,015 B
Python
#!/usr/bin/python
|
|
|
|
# A simple script to generate a file list in a format easily consumable by a
|
|
# shell script.
|
|
|
|
# Originally written by Jason Tibbitts <tibbs@math.uh.edu> in 2016.
|
|
# Donated to the public domain. If you require a statement of license, please
|
|
# consider this work to be licensed as "CC0 Universal", any version you choose.
|
|
|
|
|
|
from scandir import scandir
|
|
|
|
|
|
def get_ftype(entry):
|
|
"""Return a simple indicator of the file type."""
|
|
if entry.is_symlink():
|
|
return 'l'
|
|
if entry.is_dir():
|
|
return 'd'
|
|
return 'f'
|
|
|
|
|
|
def recursedir(path):
|
|
"""Just like scandir, but recursively."""
|
|
for entry in scandir(path):
|
|
if entry.is_dir(follow_symlinks=False):
|
|
for rentry in recursedir(entry.path):
|
|
yield rentry
|
|
yield entry
|
|
|
|
|
|
for entry in recursedir('.'):
|
|
info = entry.stat(follow_symlinks=False)
|
|
modtime = max(info.st_mtime, info.st_ctime)
|
|
ftype = get_ftype(entry)
|
|
print('{} {} {}'.format(modtime, ftype, entry.path[2:]))
|