Created
January 15, 2025 21:20
-
-
Save HaydenElza/1817562b8671b98189286580c8f3aa11 to your computer and use it in GitHub Desktop.
Power shell script to copy only the first level folders of a directory, no files or subfolders.
This file contains 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
# Source and destination paths | |
$sourcePath = "C:\source" | |
$destinationPath = "C:\destination" | |
# Get only the top-level folders | |
$folders = Get-ChildItem -Path $sourcePath -Directory | |
# Copy each folder | |
foreach ($folder in $folders) { | |
Copy-Item -Path $folder.FullName -Destination $destinationPath -Container | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment