Skip to content

Instantly share code, notes, and snippets.

@AzimsTech
Last active July 19, 2023 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AzimsTech/7de5ea26a3131bdee83f9a7b4903b1bd to your computer and use it in GitHub Desktop.
Save AzimsTech/7de5ea26a3131bdee83f9a7b4903b1bd to your computer and use it in GitHub Desktop.
Copy Current Users Directories Here
# 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