-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles_scan_example.py
More file actions
49 lines (37 loc) · 1.42 KB
/
files_scan_example.py
File metadata and controls
49 lines (37 loc) · 1.42 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
import sys
import codecs
import os
#this is my file
mypath = "c:\\users\\public\\recorded tv"
from datetime import datetime, date, time
import win32com.client
sh=win32com.client.gencache.EnsureDispatch('Shell.Application',0)
from os import listdir
from os.path import isfile, join
onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) & f.endswith(".wtv") ]
print (onlyfiles)
ns = sh.NameSpace(mypath)
targetcols = ['Title', 'Genre', 'Rating', 'Length', 'Subtitle', 'Parental rating', 'Episode name', 'Broadcast date', 'Program description', 'Station call sign']
colnames = []
colnumbs = []
for colnum in range(0,1024):
colname=ns.GetDetailsOf(None, colnum)
if colname:
for t in targetcols:
if t == colname:
colnames.append(colname)
colnumbs.append(colnum)
##for counter, colnum in enumerate(colnames):
## print (counter, colnum)
for item in ns.Items():
if isfile(item.Path)& item.Path.endswith(".wtv"):
print (item.Path)
file = os.path.basename(item.Path)
parts = file.split('_');
print (parts[0])
## for colnum in range(len(targetcols)):
## colval=ns.GetDetailsOf(item, colnumbs[colnum])
## if colval:
## print('\t', colnumbs[colnum], colnames[colnum], ":", colval)
##struct_time = datetime.strptime("10/9/2014 16:30 AM", "%m/%d/%Y %H:%M %p")
##print ("returned tuple:", struct_time)