Next: How to compare two paths of files

How to compare two paths of files



My films are stored inside th external HD.

I have a copy of backup of my film also inside the HD of my computer.

Some time I put my new film olny in my computer and I don't copy the film in my external HD.

The problem is that external HD is not aligned with my HD computer.

The following script in Powershell align the two version in fast mode......




cls
$source="C:\myfilm"
$destination="e:\myfilm"

set-location $source

$files=get-childitem -Recurse   

foreach ($file in $files)
{
 if (!$file.PsIsContainer) 
 {
  
   $src = -join($file.Directory,"\",$file)
   
   #Write-Host "Src: "$src 
   
   $new_path = $file.Directory.toString() + "\"  + $file     
   
   $new_dir = $file.Directory.toString()
   
   $dst = $new_path.replace($source,$destination)
   
   $dst_dir = $new_dir.replace($source,$destination)
  
   #Write-Host "Dst: "$dst
   
   If (!(Test-Path $dst_dir))
   {
    Write-Host " MAKE DIR: " $dst_dir
    New-Item -Path $dst_dir -ItemType "directory" | Out-Null
   }
   
   If (!(Test-Path $dst))
   {
     Write-Host "COPY FILE: " 
     Write-Host "     FROM: " $src
     Write-Host "       TO: " $dst
     Copy-Item -Path $src -Destination $dst
   }

 } 
}