I've written a script which gets the subdirectories of a given (source) directory, and then checks for the existence of a matching subdirectory in another (destination) directory. If it exists in the destination, then it copies the contents of the subdirectory in to the destination. Here's what I have so far:
$src = read-host "Enter Source Dir"
$dst = read-host "Enter Destination Dir"
$log = read-host "Enter Log File Name"
foreach ($folder in Get-ChildItem -Path $src)
{
if ( -Not (Test-Path "$dst\$folder")) {}
else {start-process robocopy.exe -ArgumentList "$src\$folder $dst\$folder /r:3 /w:5 /e /COPYALL /LOG+:D:\Temp\DataMigration\$log.log /zb /np /nc"}
}
The whole thing works quite nicely, unless the variables $src or $dst have a space within them. I also want to add a /XD Application Data argument to the argument list for robocopy, but the space in the name application data also causes errors.
Can anyone clear up how I can allow spaces where I need them as spaces rather than breaks in the script?
Thanks!
B