I have original files on one drive (J:), and run a windows 10 batch file to make a backup copy on another drive (K:). I use this command and it works great:
xcopy "J:\files" "K:\files" /d /e /f /i /v
It creates new subdirectories and does not care about the file name at all.
Now my problem is that sometimes a file from the original location on J: gets deleted and the backup copy on K: is still there taking up space when I no longer need it.
I probably need to loop through all of the files in the backup K: directory and sub directories and delete the files which can not be found in the same path on original J: location. I have tried searching StackOverflow and have found nothing close to this other than looping files in a directory. I am probably using the wrong search terms, but this seems like a common problem which should already have a solution around here somewhere.
Any help pointing me to an existing post about this, or a suggestion for what code to use would be greatly appreciated!