Last active
October 15, 2024 23:19
-
-
Save dstreefkerk/7f8910ce6ddfa8fea6206f043f353faa to your computer and use it in GitHub Desktop.
PowerShell profile function and alias to copy the current folder's filenames to clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Retrieves file names from the current folder and copies them to the clipboard. | |
Drop this function and the alias definition into your PowerShell profile file to make it available in every PowerShell session. | |
.EXAMPLE | |
Get-FileNamesFromCurrentFolder -Recurse | |
Recursively gets all file names from the current folder and subfolders, copying them to the clipboard. | |
.NOTES | |
Only file names are returned, not folder names. | |
#> | |
function Get-FileNamesFromCurrentFolder { | |
param ( | |
[switch]$Recurse | |
) | |
Get-ChildItem -File -Recurse:($Recurse.IsPresent) | Select-Object -ExpandProperty Name | Set-Clipboard | |
} | |
New-Alias -Name filenames -Value Get-FileNamesFromCurrentFolder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment