-
Notifications
You must be signed in to change notification settings - Fork 0
/
Script.ps1
57 lines (47 loc) · 1.87 KB
/
Script.ps1
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
50
51
52
53
54
55
56
57
#
# Script.ps1
#
#実行パスを定義
#$FilePath = "C:\Users\miyamam.FAREAST\Downloads\Downloader"
Param([String]$FilePath ="C:\Users\miyamam.FAREAST\Downloads\Downloader")
cd $FilePath
#ファイル名だけを取得(ダウンローダーは取得しない)
#Get-ChildItem C:\Users\miyamam.FAREAST\Downloads\Downloader -Recurse -Name -include *.pptx -Exclude *.exe
foreach($FileName in Get-ChildItem $FilePath -Recurse -Name -include *.pptx -Exclude *.exe){
#シェルオブジェクトを作成
$Shell = New-Object -ComObject Shell.Application
#フォルダの指定
$Folder = $Shell.NameSpace($FilePath)
# ファイルの指定
$File = $Folder.parseName($FileName)
# 詳細プロパティ(撮影日時)の取得
$GET = $Folder.GetDetailsOf($File,21)
$SID = $FileName.Substring(0 ,4)
#タイトルに何も入っていないときはなにもしない
if($GET -eq ""){
Write-Host $FileName
}
#タイトルにPowerPoint Presentationが入っているときもなにもしない
elseif($GET.Trim() -eq "PowerPoint Presentation"){
Write-Host $FileName
}
#タイトルに<PowerPoint Presentation>が入っているときもなにもしない
elseif($GET.Trim() -eq "<Presentation title here>"){
Write-Host $FileName
}
else{
$Oldfn = $FilePath + '\'+ $FileName
# \ / ? : * " > < | をクレンジング
$fn = $GET.Replace(":","")
$fn = $fn.Replace(" ","_")
$fn = $fn.Replace("/","")
$fn = $fn.Replace("?","")
$fn = $fn.Replace("*","")
$fn = $fn.Replace(">","")
$fn = $fn.Replace("<","")
$fn = $fn.Replace("`"","")
$Newfn = $SID + "_" + $fn + ".pptx"
Move-Item $Oldfn $Newfn -Force
Write-Host $SID $Newfn
}
}