-
Notifications
You must be signed in to change notification settings - Fork 0
/
movieList.ps1
21 lines (17 loc) · 1.96 KB
/
movieList.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$movieList = @()
$movieDir = "C:\Data\Movies\*"
$date = Get-Date -Format G
$movieFile = "C:\Users\Administrator\app\routes\movieList.txt"
Clear-Content $movieFile
for($i=0; $i -lt (Get-ChildItem $movieDir).Length;$i++){
$movieList += $(Get-ChildItem $movieDir)[$i].Name
if($movieList[$i] -Match '^\w*.+(?=.\d\d\d\d)'){
$movieList[$i] = "<tr><td>" + ($Matches[0] -Replace '\.',' ') + "</td><td>" + $(Get-ChildItem $movieDir)[$i].CreationTime + "</td></tr>"
}
else{
$movieList[$i] = "<tr><td>" + ($Matches[0] -Replace '\.',' ') + "</td><td>" + $(Get-ChildItem $movieDir)[$i].CreationTime + "</td></tr>"
}
}
"Movie List as of: $date <br /> <Table border='1'><tr><th><b>Movie Name</b></th><th><b>First added</b></th></tr>" | Out-File -FilePath $movieFile -Append -NoClobber -Encoding utf8
$movieList | Out-File -FilePath $movieFile -Append -NoClobber -Encoding utf8
"</Table>" | Out-File -FilePath $movieFile -Append -NoClobber -Encoding utf8