Last active
July 19, 2023 22:23
-
-
Save AzimsTech/7de5ea26a3131bdee83f9a7b4903b1bd to your computer and use it in GitHub Desktop.
Copy Current Users Directories Here
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
# Assign Source directory name list | |
$src_nme = "Desktop", "Documents", "Downloads", "Music", "Pictures", "Videos" | |
# Assign Destination name | |
$bak_fdr_nme = $env:UserName | |
# Assign Destination path | |
$dst_pth = "$((Get-Item .).FullName)\$($bak_fdr_nme)" | |
# Create destination directory | |
New-Item -ItemType Directory -Force -Path $dst_pth | |
$FOF_CREATEPROGRESSDLG = "&H0&" | |
$obj_shl = New-Object -ComObject "Shell.Application" | |
$obj_fdr = $obj_shl.NameSpace($dst_pth) | |
Get-ChildItem $HOME -Directory | Where-Object { $_.Name -match ( $src_nme -join '|' ) } | foreach-Object { $obj_fdr.CopyHere($_.FullName, $FOF_CREATEPROGRESSDLG) } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment