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
# Define the root directory | |
$rootDir = (Get-Location).Path | |
# Get all files in subdirectories | |
$files = Get-ChildItem -Path $rootDir -Recurse -File | |
foreach ($file in $files) { | |
# Determine the target directory (one layer after the root folder) | |
$relativePath = $file.DirectoryName.Substring($rootDir.Length).TrimStart("\") | |
$targetDir = Join-Path $rootDir ($relativePath.Split("\")[0]) |