[SOLVED] robocopy, batch files help

miket11

Distinguished
Oct 27, 2011
21
0
18,510
I'm trying to write a batch file using robocopy and if statements.

because I have a lot of files and there is never a specific file name its a little tricky.

a little background on what Im doing so it make a little more sense.

I have a Folder that is located on a shared drive/server, this Folder has files necessary for a certain software. These files are configurable and I or other people in the group can open these files and modify them as needed. Well the thing is I do not want them to save it back to this Folder on the shared driver/server before they are approved.

So what I do is require them to save it to a "Need Approval" folder on their local machine.

I need to make a script that would look at that "Need Approval" folder on each local machine and robocopy files that are in there to "Need Approval" folder on a Shared drive/server

This way I can go to "Need Approval" folder on the shared drive/server and look at files that need to be reviewed and approved. So when I review and approve the files I will move them to "Approved" folder on the Shared drive/server

So, now I need a script to also be able to take files from the "Approved" folder and move them that folder I mentioned in very beginning. That folder that has all the files for the software. This is the main Folder that can not afford to be messed up. which is why I need this whole process.

Here is a catch though. When moving files from "Approved" folder which could be anywhere from 1 file to many I do not want them to just overwrite files in the destination folder (the main important folder)

What I need is an if statement to do something like this.... or maybe some other type of solution

if a file that is about to be copied exists in destination, back it up first to a different folder and then copy. else if the file that is about to be copied doesn't exist in the destination then go ahead and copy the file
 
Solution
This really sounds more like something that's handled better by a version control system.

https://en.wikipedia.org/wiki/Version_control

There are too many different types for me to go into here. But they basically allow multiple people to modify the same files, and you can add/approve/remove each revision to the "main" version tree. You can tag a specific version of the files with a certain version number. And no matter what new changes people check in, you can revert back to that version via its version number.

It's used in larger software development projects where multiple people are working on the same source code files.
This really sounds more like something that's handled better by a version control system.

https://en.wikipedia.org/wiki/Version_control

There are too many different types for me to go into here. But they basically allow multiple people to modify the same files, and you can add/approve/remove each revision to the "main" version tree. You can tag a specific version of the files with a certain version number. And no matter what new changes people check in, you can revert back to that version via its version number.

It's used in larger software development projects where multiple people are working on the same source code files.
 
Solution