Demo entry 6345792

py

   

Submitted by anonymous on Feb 08, 2017 at 09:26
Language: Python 3. Code size: 790 Bytes.

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
#
#   Author  :   Ryan
#   E-mail  :   123@QQ.com
#   Date    :   17/02/08 14:42:35
#   Desc    :   
#
import os
import sys
import time
if_dir = {}
file_size = {}
last_mod_time = {}
if os.path.isdir(sys.argv[1]):
	dir = os.listdir(sys.argv[1])
	print("total {}".format(len(dir)))
	print("dir_or_file\tfile_size\tlast_mod_time\tpath")
	for i in dir:
		path = os.path.join(sys.argv[1],i)
		if os.path.isfile(path):
			if_dir[path] = '-'
		else:
			if_dir[path] = 'd'
		mod_time = time.localtime(os.path.getmtime(path))
		last_mod_time[path] =  time.strftime('%Y-%m-%d %H:%M:%S',mod_time)
		file_size[path] = os.path.getsize(path)
		print("{}\t{}\t{}\t{}".format(if_dir[path],file_size[path],last_mod_time[path],path))

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).