0

I need to move a whole directory structure over an existent directory structure which can be probably 90% similar. The files needed to be moved might have identical name correspondents in the directory target. It would be needed to be made a comparison of the same named files and to rename the one older with the date-name appended to the file name.

So: if source\dir1\file1 is older than target\dir1\file1 then rename source\dir1\file1 to source\dir1\file1_mod-date-time and move to target\dir1

Similarly: if source\dir1\file1 is newer than target\dir1\file1 then rename target\dir1\file1 to target\dir1\file1_mod-date-time and move source\dir1\file1 to target\dir1\

If there is no similar file in destination folder just move it there - and create a new sub-directory if not existent.

I am novice at Powershell and I tried pieces of this to make it work, but no success.

Any help would be VERY appreciated.

Thank you.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
fptstl
  • 1
  • `if($(Get-Item file1).creationtime -lt $(Get-Item file2).creationtime){}` start with this :) – Nico Nekoru Jun 09 '20 at 23:26
  • I'll try to put something together – fptstl Jun 10 '20 at 02:04
  • Try to work with foreach loops. This way you can loop through all the files in one folder and do stuff with them: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-7 – Nicicalu Jun 10 '20 at 06:09

0 Answers0