Fascix Posted July 31, 2005 Posted July 31, 2005 Oki so i SUCK BIG TIME at batch filesi need a batch file that copy 3 files from a dir to an already existing dir (that have a long dirname and spaces) ill figgure ill use XCOPY rather than COPY right?the 3 files already exists but i want them to be overwritten.please correct, simpify, make suggestions, remake this cmd for me if you willcmdow @ /HIDXCOPY /Y file1.txt "%systemdrive%\Program\Dir whit paths\dir whit paths\file1.txt"XCOPY /Y file2.txt ""%systemdrive%\Program\Dir whit paths\dir whit paths\file2.txt"XCOPY /Y file3.txt ""%systemdrive%\Program\Dir whit paths\dir whit paths\file3.txt"EXITI know this is a really newbie question but like i said i suck at batchfilesthanx for any help though
PoloDude Posted July 31, 2005 Posted July 31, 2005 If you're planing to use that batch in an unattended install, I would do place those files in the $OEM$ folder with the right directories under it.like this: $OEM$/$Progs/yada yada/file1.txtThat's how I would do it Grtz
Yzöwl Posted July 31, 2005 Posted July 31, 2005 copy /y "file 1.ext" "%systemdrive%\Dir with spaces\Subdir with spaces"also the /y switch may not be necassary
Fascix Posted July 31, 2005 Author Posted July 31, 2005 If you're planing to use that batch in an unattended install, I would do place those files in the $OEM$ folder with the right directories under it.like this: $OEM$/$Progs/yada yada/file1.txtThat's how I would do it Grtz<{POST_SNAPBACK}>Okey but does this work when the file in question already exist in the destination dir? (i want it to be overwritten! does it overwrite whitout any question?)copy /y "file 1.ext" "%systemdrive%\Dir with spaces\Subdir with spaces"also the /y switch may not be necassary<{POST_SNAPBACK}>But if i skip the /y switch i will be asked if i am sure i want to overwrite the existing file right? i just want it to be overwritten whitout any questions!How would you do such a task Yzöwl???
mau-yong Posted July 31, 2005 Posted July 31, 2005 to overwrite existing files without dos/command prompt asking you questions, you would do something like this:echo y | copy c:\thisfile.txt d:\"echo y" will automatically answer YES (y) to the file exist prompt "Overwrite d:\thisfile.txt? (Yes/No/All):"
Yzöwl Posted August 1, 2005 Posted August 1, 2005 The default behaviour is to prompt on overwrites unless the copy command is being executed from within a batch script, which in this case it is. This would negate the requirement to include it; if you wish to 'cover your bases' however there will be no harm if left in.
Fascix Posted August 1, 2005 Author Posted August 1, 2005 (edited) oki dokianything special i need to concider when useing long file/dir names and spaces in the dir/filename? do i need to enclose everything with " or just the part whit the long filename/dirname?and is there any other way of copy the 3 files instead of writing out 3 lines in the batch file with almoast the same command?some thing like this:copy file1, file2, file3 c:\bla bla bla\instead of:copy file1 c:\bla bla blacopy file2 c:\bla bla blaetc.... Edited August 1, 2005 by Fascix
Nazgul Posted August 1, 2005 Posted August 1, 2005 and is there any other way of copy the 3 files instead of writing out 3 lines in the batch file with almoast the same command?<{POST_SNAPBACK}>Take a look at the FOR /F command. You can get some additional information about it by executing HELP FOR from a command prompt.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now