Question:
CMD help please, .bat files?
anonymous
2007-12-03 15:43:47 UTC
Hi,
can someone please tell me, what would be the script for a .bat file in notepad if i wanted to do the following:

copy "x" into the startup folder, assuming x stands for the program I want to copy,

I am learning about this new topic to thanks in advance
Three answers:
inclusive_disjunction
2007-12-03 15:48:19 UTC
COPY C:\Directory\File.ext C:\Target\new.ext
wrkey
2007-12-03 23:59:46 UTC
If you know the commands to send in DOS, then you know how to build a 'bat' file. The trick is sending 'variables' to the commands. Batch files use the %# format for sending variables. Let's say we create a batch file called StartCopy.BAT. When we invoke this command file we will append the name of the file (justafile.txt) to it so it looks like the following line:



StartCopy justafile.txt



Now we just think about how the steps we want to make this happen with. First we must assume that file name variable will contain the complete path to locate the file. Then we simply create the following line in the batch file:



copy %1 c:\startup\



This will do the trick for you. If your copying the same file everytime, just use the command "copy justafile.txt c:\startup\" in the batch file and that will do the trick as well. The variable process just gives you the ability to use the same command for multiple files and shows how the variable thing works. If you have mutiple files you can use multiple variables to make it work. Then your batch file would look like:



copy %1 c:\startup\

copy %2 c:\startup\

copy %3 c:\startup\



And the command would be:

StartCopy Justafile.txt another.txt third.txt



Hope this answers the question!
nb_philly
2007-12-03 23:52:23 UTC
@copy d:\folder\x .



if the startup folder is where you are executing the batch file.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...