mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-17 02:01:01 +01:00
Update list-special-folders.ps1
This commit is contained in:
parent
b1798e378b
commit
8876c5c003
@ -2,13 +2,13 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists special folders
|
Lists special folders
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script lists all special folders (sorted alphabetically).
|
This PowerShell script lists the special folders (sorted alphabetically).
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-special-folders
|
PS> ./list-special-folders
|
||||||
|
|
||||||
Folder Name Folder Path
|
Folder Name Folder Path
|
||||||
----------- -----------
|
----------- -----------
|
||||||
📂Autostart C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
|
AdminTools 📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools
|
||||||
...
|
...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -24,43 +24,37 @@ function GetTempDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function AddLine { param([string]$FolderName, [string]$FolderPath)
|
function AddLine { param([string]$FolderName, [string]$FolderPath)
|
||||||
New-Object PSObject -property @{ 'Folder Name' = "$FolderName"; 'Folder Path' = "$FolderPath" }
|
New-Object PSObject -property @{ 'Folder Name' = "$FolderName"; 'Folder Path' = "📂$FolderPath" }
|
||||||
}
|
}
|
||||||
|
|
||||||
function ListSpecialFolders {
|
function ListSpecialFolders {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
AddLine "📂Desktop" "$HOME/Desktop"
|
AddLine "Desktop" "$HOME/Desktop"
|
||||||
AddLine "📂Downloads" "$HOME/Downloads"
|
AddLine "Downloads" "$HOME/Downloads"
|
||||||
AddLine "📂Home Folder" "$HOME"
|
AddLine "Home Folder" "$HOME"
|
||||||
AddLine "📂My Documents" "$HOME/Documents"
|
AddLine "MyDocuments" "$HOME/Documents"
|
||||||
AddLine "📂My Music" "$HOME/Music"
|
AddLine "MyMusic" "$HOME/Music"
|
||||||
AddLine "📂My Pictures" "$HOME/Pictures"
|
AddLine "MyPictures" "$HOME/Pictures"
|
||||||
AddLine "📂My Screenshots" "$HOME/Pictures/Screenshots"
|
AddLine "MyScreenshots" "$HOME/Pictures/Screenshots"
|
||||||
AddLine "📂My Videos" "$HOME/Videos"
|
AddLine "MyVideos" "$HOME/Videos"
|
||||||
AddLine "📂Temporary Folder" "$(GetTempDir)"
|
AddLine "Temporary Folder" "$(GetTempDir)"
|
||||||
$Path = Resolve-Path "$HOME/.."
|
$Path = Resolve-Path "$HOME/.."
|
||||||
AddLine "📂Users" "$Path"
|
AddLine "Users" "$Path"
|
||||||
} else {
|
} else {
|
||||||
$Path = Resolve-Path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
|
$FolderNames = [System.Enum]::GetNames('System.Environment+SpecialFolder')
|
||||||
AddLine "📂Autostart" "$Path"
|
$FolderNames | Sort-Object | ForEach-Object {
|
||||||
AddLine "📂Desktop" "$([Environment]::GetFolderPath('DesktopDirectory'))"
|
if ($Path = [System.Environment]::GetFolderPath($_)) {
|
||||||
AddLine "📂Downloads" "$((New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path)"
|
AddLine "$_" "$Path"
|
||||||
AddLine "📂Fonts" "$([Environment]::GetFolderPath('Fonts'))"
|
}
|
||||||
AddLine "📂Home Folder" "$HOME"
|
}
|
||||||
AddLine "📂My Documents" "$([Environment]::GetFolderPath('MyDocuments'))"
|
AddLine "TemporaryFolder" "$(GetTempDir)"
|
||||||
AddLine "📂My Music" "$([Environment]::GetFolderPath('MyMusic'))"
|
|
||||||
AddLine "📂My Pictures" "$([Environment]::GetFolderPath('MyPictures'))"
|
|
||||||
AddLine "📂My Screenshots" "$([Environment]::GetFolderPath('MyPictures'))\Screenshots"
|
|
||||||
AddLine "📂My Videos" "$([Environment]::GetFolderPath('MyVideos'))"
|
|
||||||
AddLine "📂Temporary Folder" "$(GetTempDir)"
|
|
||||||
$Path = Resolve-Path "$HOME/.."
|
$Path = Resolve-Path "$HOME/.."
|
||||||
AddLine "📂Users" "$Path"
|
AddLine "Users" "$Path"
|
||||||
AddLine "📂Windows" "$([Environment]::GetFolderPath('Windows'))"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ListSpecialFolders | Format-Table -property @{e='Folder Name';width=20},'Folder Path'
|
ListSpecialFolders | Format-Table -property @{e='Folder Name';width=22},'Folder Path'
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user