MSFN Forum: Just a simple batch file - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Just a simple batch file need suggestions, corrections etc Rate Topic: -----

#1 User is offline   Fascix 

  • The Swedish Steel
  • Pip
  • Group: Members
  • Posts: 94
  • Joined: 10-May 05

Posted 31 July 2005 - 03:50 PM

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


#2 User is offline   PoloDude 

  • Junior
  • Pip
  • Group: Members
  • Posts: 57
  • Joined: 08-June 04

Posted 31 July 2005 - 04:18 PM

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

#3 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 July 2005 - 05:03 PM

copy /y "file 1.ext" "%systemdrive%\Dir with spaces\Subdir with spaces"
also the /y switch may not be necassary

#4 User is offline   Fascix 

  • The Swedish Steel
  • Pip
  • Group: Members
  • Posts: 94
  • Joined: 10-May 05

Posted 31 July 2005 - 05:18 PM

PoloDude, on Aug 1 2005, 12:18 AM, said:

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

Yzöwl, on Aug 1 2005, 01:03 AM, said:

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

#5 User is offline   mau-yong 

  • silent, swift and deadly
  • PipPip
  • Group: Members
  • Posts: 148
  • Joined: 01-June 05
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 31 July 2005 - 05:35 PM

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

#6 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 July 2005 - 06:22 PM

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.

#7 User is offline   Fascix 

  • The Swedish Steel
  • Pip
  • Group: Members
  • Posts: 94
  • Joined: 10-May 05

Posted 01 August 2005 - 01:19 AM

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

This post has been edited by Fascix: 01 August 2005 - 01:22 AM


#8 User is offline   Nazgul 

  • Junior
  • Pip
  • Group: Members
  • Posts: 86
  • Joined: 02-January 05

Posted 01 August 2005 - 02:28 AM

Fascix, on Aug 1 2005, 08:19 AM, said:

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.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy