本ページには広告が含まれています。
目次
- 構文
- FolderItem = FolderItems.Item( iIndex )
- 引数
- iIndex 省略可
- 取得するFolderItemオブジェクトの番号を数値で指定。0〜FolderItems.Count-1の範囲で指定。
FolderItems オブジェクトを返すメソッド・プロパティ
- FolderItems.Item メソッド
- フォルダ内のアイテムのコレクションを表すFolderItems オブジェクトを取得します。
- FolderItems.Item メソッド
- アイテムの親を示すオブジェクトを取得します。
プログラム実行例
デスクトップのファイル一覧
CONST ssfDESKTOP = 0
HASHTBL iColumn
DIM Shell = CREATEOLEOBJ("Shell.Application")
DIM Folder = Shell.NameSpace(ssfDESKTOP)
DIM FolderItems = Folder.Items
FOR n = 0 TO 350
iColumn[Folder.GetDetailsOf(EMPTYPARAM, n)] = n
NEXT
FOR n = 0 TO FolderItems.Count - 1
DIM FolderItem = FolderItems.Item(n)
WITH FolderItem
PRINT .Name
PRINT .Size + " Byte"
PRINT .Type
ENDWITH
PRINT "-----"
NEXT
使用関数
解説
フォルダ内のファイルを更新日時でソートする
DIM Shell = CREATEOLEOBJ("Shell.Application")
DIM Folder = Shell.NameSpace("C:\Program Files (x86)\UWSC")
DIM FolderItems = Folder.Items
HASHTBL iColumn
FOR i = 0 TO 350
iColumn[Folder.GetDetailsOf(EMPTYPARAM, i)] = i
NEXT
DIM filename[-1]
DIM datetime[-1]
FOR i = 0 TO FolderItems.Count - 1
DIM FolderItem = FolderItems.Item(i)
IF FolderItem.isFolder THEN CONTINUE
arrayPush(filename, Folder.GetDetailsOf(FolderItem,iColumn["名前"]))
arrayPush(datetime, Folder.GetDetailsOf(FolderItem, iColumn["更新日時"]))
NEXT
QSORT(datetime, QSRT_NATURALA, filename)
FOR i = 0 TO UBound(filename)
PRINT filename[i] + "<#TAB>" + datetime[i]
NEXT
結果
UDebug.chm 2014/05/11 1:58
RecIE.chm 2014/05/11 1:58
Uws2Exe.chm 2015/08/13 16:12
RecUws.dll 2016/03/25 4:57
UWSC.exe 2016/10/15 13:33
Uws2Exe.exe 2016/10/15 13:34
RecIE.exe 2016/10/15 13:35
UDebug.exe 2016/10/15 13:37
XRef.exe 2016/10/15 13:38
Readme.txt 2016/10/15 13:39
uwsc.chm 2016/10/15 13:41
unins000.exe 2018/06/27 12:48
unins000.dat 2018/06/27 12:49
使用関数
写真を撮影日時毎にフォルダ分けする
CONST ssfMYPICTURES = 39
DIM Folder[1]
DIM folderspec[1]
DIM Shell = CREATEOLEOBJ("Shell.Application")
folderspec[0] = "D:\Pictures\100ANDRO\"
Folder[0] = Shell.NameSpace(folderspec[0])
DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject")
HASHTBL iColumn
FOR i = 0 TO 350
iColumn[Folder[0].GetDetailsOf(EMPTYPARAM, i)] = i
NEXT
DIM destination[-1]
DIM path[-1]
DIM cnt = Folder[0].Items.Count - 1
FOR i = cnt TO 0 STEP -1
FUKIDASI(i + "/" + cnt)
DIM FolderItem = Folder[0].Items.Item(i)
IF FolderItem.isFolder THEN CONTINUE
DIM filename = FolderItem.Name
DIM datetime = deleteControlCharacter(Folder[0].GetDetailsOf(FolderItem, iColumn["撮影日時"]))
PRINT filename
PRINT datetime
PRINT "-----"
TRY
DIM date = text(dateValue(datetime), "yyyy-mm-dd")
EXCEPT
date = "0000-00-00"
ENDTRY
folderspec[1] = FSO.BuildPath(folderspec[0], date)
Folder[1] = Shell.NameSpace(folderspec[1])
arrayPush(destination, folderspec[1])
arrayPush(path, FolderItem.Path)
NEXT
FOR i = 0 TO UBound(destination)
IF !FSO.FolderExists(destination[i]) THEN CreateFolders(destination[i])
Folders = Shell.NameSpace(destination[i])
Folders.MoveHere(path[i])
NEXT
FUNCTION deleteControlCharacter(str)
DIM array[] = CHR(8206), CHR(8207)
FOR item IN array
str = REPLACE(str, item, "")
NEXT
RESULT = str
FEND
使用関数
デフォルトプリンターを取得
CONST ssfPRINTERS = 4
DIM Shell = CREATEOLEOBJ("Shell.Application")
DIM Folder = Shell.NameSpace(ssfPRINTERS)
DIM FolderItems = Folder.Items
HASHTBL iColumn
FOR n = 0 TO 350
iColumn[Folder.GetDetailsOf(EMPTYPARAM, n)] = n
NEXT
FOR n = 0 TO FolderItems.Count - 1
DIM FolderItem = FolderItems.Item(n)
DIM PrinterName = Folder.GetDetailsOf(FolderItem, iColumn["名前"])
FOR i = 0 TO FolderItem.Verbs.Count - 1
IF POS("通常使うプリンターに設定", FolderItem.Verbs.Item(i).Name) <> 0 THEN CONTINUE 2
NEXT
PRINT PrinterName
BREAK
NEXT
結果
Brother DCP-J963N Printer
使用関数
指定したディレクトリ内のフォルダ・ファイル情報を取得
CONST ssfDesktop = 0
DIM Shell = CREATEOLEOBJ("Shell.Application")
DIM Folder = Shell.BrowseForFolder(0, "フォルダを選択してください。", 0, ssfDesktop)
FOR n = 0 TO Folder.Items.Count - 1
DIM FolderItem = Folder.Items.Item(n)
WITH FolderItem
PRINT "名前<#TAB><#TAB>" + .Name
PRINT "サイズ<#TAB><#TAB>" + .Size + " Byte"
PRINT "更新日時<#TAB>" + .ModifyDate
PRINT "パス<#TAB><#TAB>" + .Path
PRINT "種類<#TAB><#TAB>" + .Type
ENDWITH
PRINT "----------"
NEXT
使用関数
ファイルシステムかどうか
DIM Shell = CREATEOLEOBJ("Shell.Application")
DIM Folder = Shell.NameSpace("C:\Windows")
DIM FolderItems = Folder.Items
FOR n = 0 TO FolderItems.Count - 1
DIM FolderItem = FolderItems.Item(n)
WITH FolderItem
PRINT .IsFileSystem + "<#TAB>" + .Name
ENDWITH
NEXT
使用関数