-
Notifications
You must be signed in to change notification settings - Fork 0
/
LocalImgShelveScanner.ps1
41 lines (32 loc) · 1.26 KB
/
LocalImgShelveScanner.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
$path = $PSScriptRoot
write-host $PSScriptRoot
$script:json = ""
function get-folders {
Param ($path)
$items = Get-ChildItem -LiteralPath "$path"
foreach ($item in $items) {
# List all the folders
if ($item.Mode -eq "d-----") {
$script:json += "{"
$script:json += "`"folder`":`"$item`","
$script:json += "`"contents`":"
$script:json += "["
$itemname = $item.Name
$fullpath = "$path\$itemname"
write-host $fullpath
get-folders $fullpath #Recursively list if it is a directory
$script:json += "]"
$script:json += "},"
}
# Print out any files
#if (($item.Mode -eq "-a----") -and ($item.Extension.ToLower() -in @('.apng','.avif','.gif','.jpg','.jpeg','.jfif','.pjpeg','.pjp','.png','.svg','.webp','.bmp','.ico','.cur','.tif','.tiff'))) {
if ($item.Extension.ToLower() -in @('.apng','.avif','.gif','.jpg','.jpeg','.jfif','.pjpeg','.pjp','.png','.svg','.webp','.bmp','.ico','.cur','.tif','.tiff')) {
$script:json += "`"$item`","
}
}
}
$script:json += "records=["
get-folders $path
$script:json += "]"
#write-host $script:json
$script:json | Out-File -FilePath "$PSScriptRoot\LocalImgShelveJson.txt"