Jump to content

Just a simple batch file


Recommended Posts

Oki so i SUCK BIG TIME at batch files

i 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 will

cmdow @ /HID

XCOPY /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"

EXIT

I know this is a really newbie question but like i said i suck at batchfiles

thanx for any help though

Link to comment
Share on other sites


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.txt

That's how I would do it :)

Grtz

Link to comment
Share on other sites

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.txt

That's how I would do it :)

Grtz

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

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???

Link to comment
Share on other sites

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):" :thumbup

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

oki doki

anything 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 bla

copy file2 c:\bla bla bla

etc....

Edited by Fascix
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...