| 1. |
Solve : If Copy Batch File Help? |
|
Answer» Hello, I need some assistance in making a batch file. I need the file to check if a file exists in a location, if it does I need it to be renamed, and then copy a target file to that same directory. It has to look at a few directories, but I should be able to write that in after the fact. Hello, I need some assistance in making a batch file. Is it assistance you need, or do you want the script written? Quote I need the file to check if a file exists in a location, if it does I need it to be renamed, and then copy a target file to that same directory. It has to look at a few directories, but I should be able to write that in after the fact. If you want a working script then details about the task are needed. I would suggest you look up the semantics of the CMD.EXE CALL :label [args] command extension. Using this, you could create a "function" which would expect a source and destination path, and if the file already exists at the destination, rename it then copy. Then you can call this function for each source/destination combo you need. I just gave a similar script in this topic: Move script file to users adobe folderIt will always be the same file name in this case. I'm just trying to copy over a report file that serves as a template, but the problem is that the program has been installed at different directories and as far as I know there isn't an environment variable for me to use. I'm a bit lackluster in scripting so I was hoping for some code I can try to make sense of. Casteele's example in the other post is a bit confusing for me. Please let me know if there are any more details I can provide, I'm not intentionally trying to be vague.Quote from: fdskl on December 01, 2015, 06:50:27 AM It will always be the same file name in this case. That makes it easier. Quote I'm just trying to copy over a report file that serves as a template, but the problem is that the program has been installed at different directories And where are these folders, and what are they called? Quote I was hoping for some code I can try to make sense of. It'll be a piece of cake when we have some details that we can make sense of. Quote from: foxidrive on December 03, 2015, 03:03:15 AM
Post #3 has that information.Quote from: fdskl on December 03, 2015, 12:54:21 PM Post #3 has that information. Post #3 has bogus information though. You MAY like to consider the thought that you're asking for exact code to solve a problem, and giving details that are inexact. If you gain experience in solving problems for other people then you will understand how often you have to change the code you have already provided (free of charge), because the details you were given were wrong, or information was withheld. C:\Program Files (x86)\nise\inv.rpt C:\Program Files\nise\inv.rpt C:\nise\inv.rpt copy "%~dp0\inv.rpt" There's the exact paths, hope that adds some clarity. Thank you for your patience. |
|