フォルダ内のアイコンを任意の順序にする。(その2)
GUIで並びを変更します。並びの順にアクセス日時を変更します。
folder.hta [フォルダパス]
<html>
<head>
<meta charset="shift_jis">
<title></title>
<hta:application id="hta"/>
<script language=vbscript>
Option Explicit
Sub window_onload
Dim fQuoting
Dim k
fQuoting=False
For k=1 To Len(hta.commandLine)
Select Case Mid(hta.commandLine,k,1)
Case Chr(34) fQuoting=Not fQuoting
Case Chr(32) If Not fQuoting Then Exit For
End Select
Next
Dim Path
Path=Replace(Mid(hta.commandLine,k+1),"""","")
If Path<>"" Then
NavigateX Path
Else
BrowseForFolder
End If
End Sub
Sub BrowseForFolder
Dim Folder
Set Folder=CreateObject("Shell.Application").BrowseForFolder(0,"",0)
If Not Folder Is Nothing Then
NavigateX Folder.Self.Path
End If
End Sub
Sub ChangeAccessTime
Dim oExec
Set oExec=CreateObject("WScript.Shell").Exec("powershell.exe ""$input | foreach {$i=[datetime]::today}{set-itemproperty -literalpath $_ -name lastaccesstime -value $i;$i=$i.addminutes(1)}""")
Dim FolderItem
For Each FolderItem In ShellFolderView().Folder.Items
oExec.StdIn.WriteLine FolderItem.Path
Next
oExec.StdIn.Close
End Sub
Sub NavigateX(Path)
If Path<>"" Then
document.title=Path
WebOC.Navigate Path
text.value=Path
End If
End Sub
</script>
<script language="JavaScript">
function ShellFolderView() {
return WebOC.Document;
}
</script>
</head>
<body>
<div>
<INPUT type=button value="フォルダ参照" onclick="BrowseForFolder">
<INPUT type=text id="text" size=119>
<INPUT type=button value="フォルダ移動" onclick="NavigateX text.value">
<INPUT type=button value="並びを保存" onclick="ChangeAccessTime">
</div>
<object id="WebOC" classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2" width="100%" height=400 VIEWASTEXT></object>
</body>
</html>