Link to home
Start Free TrialLog in
Avatar of Sam OZ
Sam OZFlag for Australia

asked on

move files to a single folder destination

I need to move all files in a folder ( including files in a sub folder)  to a single folder at destination
can I get the robocopy or powershell script for that
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi!

Here is a Powershell script you can incorporate. Make sure to replace "C:\Path\To\Source\Folder" with the actual path to your source folder and "C:\Path\To\Destination\Folder" with the actual path to your destination folder.

$sourceFolder = "C:\Path\To\Source\Folder"
$destinationFolder = "C:\Path\To\Destination\Folder"

# Get all files from the source folder and its subfolders
$files = Get-ChildItem -Path $sourceFolder -File -Recurse

# Move each file to the destination folder
foreach ($file in $files) {
    $destinationPath = Join-Path -Path $destinationFolder -ChildPath $file.Name
    Move-Item -Path $file.FullName -Destination $destinationPath -Force
}

Open in new window

Using jpsoft's shells such as TCC/LE
cdd c:\source_tree
global copy *.* d:\destination\