Batch file

G

Guest

Guest
Archived from groups: microsoft.public.win2000.general (More info?)

I need some help on this one. I want to copy all files from my C:\test to
G:\Backup. In addition I want to create a text file that displays the date
and time started and date and time finished. I want to script using a batch
file.
 

Royce

Distinguished
Jul 3, 2004
64
0
18,630
Archived from groups: microsoft.public.win2000.general (More info?)

Or this...

@echo off
title COPYING FILES...
for /l %%i in (1,1,11) do echo.
echo Please Wait While Files Are Being Copied...
echo Started Copying Files On %date% At %time% >>
%Userprofile%\Desktop\test.txt
xcopy C:\test G:\backup /e /c /f /h /y >> %Userprofile%\Desktop\test.txt
echo Stopped Copying Files On %date% At %time% >>
%Userprofile%\Desktop\test.txt
exit

"George Schneider" wrote:

> I need some help on this one. I want to copy all files from my C:\test to
> G:\Backup. In addition I want to create a text file that displays the date
> and time started and date and time finished. I want to script using a batch
> file.
>
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.general (More info?)

"George Schneider" <georgedschneider@news.postalias> wrote in message
news:9FA34A58-A4AE-4376-9B62-FB03A3C53AF7@microsoft.com...
> I need some help on this one. I want to copy all files from my C:\test
to
> G:\Backup. In addition I want to create a text file that displays the
date
> and time started and date and time finished. I want to script using a
batch
> file.
>

Try this:

@echo off
echo Copy process started on %date% at %time% > c:\Log.txt
xcopy /y c:\test g:\backup\ >> c:\Log.txt
echo Copy process ended on %date% at %time% >> c:\Log.txt
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.general (More info?)

I wasn't even aware of the "Title" command. Good one!
Your code contains a small error. All your redirections should read

>> "%Userprofile%\Desktop\test.txt"

i.e. with the surrounding double quotes (which I'm sure you're aware of!).
Furthermore, the "exit" command is superfluous.


"Royce" <Royce@discussions.microsoft.com> wrote in message
news:43733E19-6F67-4F01-A3EA-7316AAB0C97A@microsoft.com...
> Or this...
>
> @echo off
> title COPYING FILES...
> for /l %%i in (1,1,11) do echo.
> echo Please Wait While Files Are Being Copied...
> echo Started Copying Files On %date% At %time% >>
> %Userprofile%\Desktop\test.txt
> xcopy C:\test G:\backup /e /c /f /h /y >> %Userprofile%\Desktop\test.txt
> echo Stopped Copying Files On %date% At %time% >>
> %Userprofile%\Desktop\test.txt
> exit
>
> "George Schneider" wrote:
>
> > I need some help on this one. I want to copy all files from my C:\test
to
> > G:\Backup. In addition I want to create a text file that displays the
date
> > and time started and date and time finished. I want to script using a
batch
> > file.
> >
 

Royce

Distinguished
Jul 3, 2004
64
0
18,630
Archived from groups: microsoft.public.win2000.general (More info?)

i am aware of the quotes and when to use them. correct me if i wrong, you use
them when there are spaces in the path. "%Userprofile%\Desktop\test.txt"
should work the same as %Userprofile%\Desktop\test.txt and the exit thing is
just something i have always done : ) i was unaware of the exit /b vs. exit.
learn something new everyday. so pegasus when would exit be needed?


"Pegasus (MVP)" wrote:

> I wasn't even aware of the "Title" command. Good one!
> Your code contains a small error. All your redirections should read
>
> >> "%Userprofile%\Desktop\test.txt"
>
> i.e. with the surrounding double quotes (which I'm sure you're aware of!).
> Furthermore, the "exit" command is superfluous.
>
>
> "Royce" <Royce@discussions.microsoft.com> wrote in message
> news:43733E19-6F67-4F01-A3EA-7316AAB0C97A@microsoft.com...
> > Or this...
> >
> > @echo off
> > title COPYING FILES...
> > for /l %%i in (1,1,11) do echo.
> > echo Please Wait While Files Are Being Copied...
> > echo Started Copying Files On %date% At %time% >>
> > %Userprofile%\Desktop\test.txt
> > xcopy C:\test G:\backup /e /c /f /h /y >> %Userprofile%\Desktop\test.txt
> > echo Stopped Copying Files On %date% At %time% >>
> > %Userprofile%\Desktop\test.txt
> > exit
> >
> > "George Schneider" wrote:
> >
> > > I need some help on this one. I want to copy all files from my C:\test
> to
> > > G:\Backup. In addition I want to create a text file that displays the
> date
> > > and time started and date and time finished. I want to script using a
> batch
> > > file.
> > >
>
>
>
 

Rob

Distinguished
Dec 31, 2007
1,573
0
19,780
Archived from groups: microsoft.public.win2000.general (More info?)

http://www.janko.at/Humor/Microsoft/Undokumentierte%20DOS-Kommandos.htm

I used to work in a computer store and one day we had a gentleman call in
with a smoking power supply. The service rep was having a bit of trouble
convincing this guy that he had a hardware problem.Service Rep: Sir,
something has burnt within your power supply.

Customer:
I bet that there is some command that I can put into the Autoexec.bat that
will take care of this.

Service Rep:
There is nothing that software can do to help you with this problem.

Customer:
I know that there is something that I can put in... some command... maybe it
should go into the Config.sys.

[After a few minutes of going round and round]

Service Rep:
Okay, I am not supposed to tell anyone this but there is a hidden command in
some versions of DOS that you can use. I want you to edit your Autoexec.bat
and add the last line as C:\DOS\NOSMOKE and reboot your computer.

[Customer does this]

Customer:
It is still smoking.

Service Rep:
I guess you need to call MicroSoft and ask them for a patch for the
NOSMOKE.EXE.

[The customer then hung up. We thought that we had heard the last of this
guy but NO... he calls back four hours later]

Service Rep:
Hello Sir, how is your computer?

Customer:
I call MicroSoft and they said that my Power Supply is incompatible with
their NOSMOKE.EXE and that I need to get a new one. I was wondering when I
can have that done and how much it will cost...

Moral: Remember those hidden DOS commands!

"Royce" <Royce@discussions.microsoft.com> wrote in message
news:E07B223E-E274-4F97-807A-2B86753298BA@microsoft.com...
> i am aware of the quotes and when to use them. correct me if i wrong, you
use
> them when there are spaces in the path. "%Userprofile%\Desktop\test.txt"
> should work the same as %Userprofile%\Desktop\test.txt and the exit thing
is
> just something i have always done : ) i was unaware of the exit /b vs.
exit.
> learn something new everyday. so pegasus when would exit be needed?
>
>
> "Pegasus (MVP)" wrote:
>
> > I wasn't even aware of the "Title" command. Good one!
> > Your code contains a small error. All your redirections should read
> >
> > >> "%Userprofile%\Desktop\test.txt"
> >
> > i.e. with the surrounding double quotes (which I'm sure you're aware
of!).
> > Furthermore, the "exit" command is superfluous.
> >
> >
> > "Royce" <Royce@discussions.microsoft.com> wrote in message
> > news:43733E19-6F67-4F01-A3EA-7316AAB0C97A@microsoft.com...
> > > Or this...
> > >
> > > @echo off
> > > title COPYING FILES...
> > > for /l %%i in (1,1,11) do echo.
> > > echo Please Wait While Files Are Being Copied...
> > > echo Started Copying Files On %date% At %time% >>
> > > %Userprofile%\Desktop\test.txt
> > > xcopy C:\test G:\backup /e /c /f /h /y >>
%Userprofile%\Desktop\test.txt
> > > echo Stopped Copying Files On %date% At %time% >>
> > > %Userprofile%\Desktop\test.txt
> > > exit
> > >
> > > "George Schneider" wrote:
> > >
> > > > I need some help on this one. I want to copy all files from my
C:\test
> > to
> > > > G:\Backup. In addition I want to create a text file that displays
the
> > date
> > > > and time started and date and time finished. I want to script using
a
> > batch
> > > > file.
> > > >
> >
> >
> >
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.general (More info?)

You can use the "exit" command in a batch file if you
wish to terminate it before it reaches the end, e.g. like so:

@echo off
if not exist c:\SomeFile.txt exit /b

This is equivalent to writing:

@echo off
if not exist c:\SomeFile.txt goto :eof

However, if you use this syntax:

@echo off
if not exist c:\SomeFile.txt exit

then the batch file will terminat and the current Command
Prompt (if you use one) will be closed too. This may not
be what you had intended.

The %UserProfile% variable includes embedded spaces
after it gets resolved (usually to c:\documents and settings\UserName).
This is why the double quotes are required. You can easily confirm
this by typing the following lines at the Command Prompt:

echo. > test.txt
copy test.txt "%UserProfile%"
copy test.txt %UserProfile%

The third command will fail.


"Royce" <Royce@discussions.microsoft.com> wrote in message
news:E07B223E-E274-4F97-807A-2B86753298BA@microsoft.com...
> i am aware of the quotes and when to use them. correct me if i wrong, you
use
> them when there are spaces in the path. "%Userprofile%\Desktop\test.txt"
> should work the same as %Userprofile%\Desktop\test.txt and the exit thing
is
> just something i have always done : ) i was unaware of the exit /b vs.
exit.
> learn something new everyday. so pegasus when would exit be needed?
>
>
> "Pegasus (MVP)" wrote:
>
> > I wasn't even aware of the "Title" command. Good one!
> > Your code contains a small error. All your redirections should read
> >
> > >> "%Userprofile%\Desktop\test.txt"
> >
> > i.e. with the surrounding double quotes (which I'm sure you're aware
of!).
> > Furthermore, the "exit" command is superfluous.
> >
> >
> > "Royce" <Royce@discussions.microsoft.com> wrote in message
> > news:43733E19-6F67-4F01-A3EA-7316AAB0C97A@microsoft.com...
> > > Or this...
> > >
> > > @echo off
> > > title COPYING FILES...
> > > for /l %%i in (1,1,11) do echo.
> > > echo Please Wait While Files Are Being Copied...
> > > echo Started Copying Files On %date% At %time% >>
> > > %Userprofile%\Desktop\test.txt
> > > xcopy C:\test G:\backup /e /c /f /h /y >>
%Userprofile%\Desktop\test.txt
> > > echo Stopped Copying Files On %date% At %time% >>
> > > %Userprofile%\Desktop\test.txt
> > > exit
> > >
> > > "George Schneider" wrote:
> > >
> > > > I need some help on this one. I want to copy all files from my
C:\test
> > to
> > > > G:\Backup. In addition I want to create a text file that displays
the
> > date
> > > > and time started and date and time finished. I want to script using
a
> > batch
> > > > file.
> > > >
> >
> >
> >
 

Royce

Distinguished
Jul 3, 2004
64
0
18,630
Archived from groups: microsoft.public.win2000.general (More info?)

Thanks for all the info Pegasus. I tried your test:
echo. > test.txt
copy test.txt "%UserProfile%"
copy test.txt %UserProfile%
and you are absolutely correct. I will start using quotes in my path from
now on! Even if they are not required.


"Pegasus (MVP)" wrote:

> You can use the "exit" command in a batch file if you
> wish to terminate it before it reaches the end, e.g. like so:
>
> @echo off
> if not exist c:\SomeFile.txt exit /b
>
> This is equivalent to writing:
>
> @echo off
> if not exist c:\SomeFile.txt goto :eof
>
> However, if you use this syntax:
>
> @echo off
> if not exist c:\SomeFile.txt exit
>
> then the batch file will terminat and the current Command
> Prompt (if you use one) will be closed too. This may not
> be what you had intended.
>
> The %UserProfile% variable includes embedded spaces
> after it gets resolved (usually to c:\documents and settings\UserName).
> This is why the double quotes are required. You can easily confirm
> this by typing the following lines at the Command Prompt:
>
> echo. > test.txt
> copy test.txt "%UserProfile%"
> copy test.txt %UserProfile%
>
> The third command will fail.
>
>
> "Royce" <Royce@discussions.microsoft.com> wrote in message
> news:E07B223E-E274-4F97-807A-2B86753298BA@microsoft.com...
> > i am aware of the quotes and when to use them. correct me if i wrong, you
> use
> > them when there are spaces in the path. "%Userprofile%\Desktop\test.txt"
> > should work the same as %Userprofile%\Desktop\test.txt and the exit thing
> is
> > just something i have always done : ) i was unaware of the exit /b vs.
> exit.
> > learn something new everyday. so pegasus when would exit be needed?
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> > > I wasn't even aware of the "Title" command. Good one!
> > > Your code contains a small error. All your redirections should read
> > >
> > > >> "%Userprofile%\Desktop\test.txt"
> > >
> > > i.e. with the surrounding double quotes (which I'm sure you're aware
> of!).
> > > Furthermore, the "exit" command is superfluous.
> > >
> > >
> > > "Royce" <Royce@discussions.microsoft.com> wrote in message
> > > news:43733E19-6F67-4F01-A3EA-7316AAB0C97A@microsoft.com...
> > > > Or this...
> > > >
> > > > @echo off
> > > > title COPYING FILES...
> > > > for /l %%i in (1,1,11) do echo.
> > > > echo Please Wait While Files Are Being Copied...
> > > > echo Started Copying Files On %date% At %time% >>
> > > > %Userprofile%\Desktop\test.txt
> > > > xcopy C:\test G:\backup /e /c /f /h /y >>
> %Userprofile%\Desktop\test.txt
> > > > echo Stopped Copying Files On %date% At %time% >>
> > > > %Userprofile%\Desktop\test.txt
> > > > exit
> > > >
> > > > "George Schneider" wrote:
> > > >
> > > > > I need some help on this one. I want to copy all files from my
> C:\test
> > > to
> > > > > G:\Backup. In addition I want to create a text file that displays
> the
> > > date
> > > > > and time started and date and time finished. I want to script using
> a
> > > batch
> > > > > file.
> > > > >
> > >
> > >
> > >
>
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.general (More info?)

Hahaha. There is probably a need to update your joke a little
There is no DOS under Windows, there is only a Command Prompt.
DOS is an operating system, same as Unix. Let's not confuse the
OP with inappropriate buzzwords!


"Rob" <rob_brownNOSPAM@NOSPAMsofthome.net> wrote in message
news:OFQ89l0ZFHA.3976@TK2MSFTNGP15.phx.gbl...
> http://www.janko.at/Humor/Microsoft/Undokumentierte%20DOS-Kommandos.htm
>
> I used to work in a computer store and one day we had a gentleman call in
> with a smoking power supply. The service rep was having a bit of trouble
> convincing this guy that he had a hardware problem.Service Rep: Sir,
> something has burnt within your power supply.
>
> Customer:
> I bet that there is some command that I can put into the Autoexec.bat that
> will take care of this.
>
> Service Rep:
> There is nothing that software can do to help you with this problem.
>
> Customer:
> I know that there is something that I can put in... some command... maybe
it
> should go into the Config.sys.
>
> [After a few minutes of going round and round]
>
> Service Rep:
> Okay, I am not supposed to tell anyone this but there is a hidden command
in
> some versions of DOS that you can use. I want you to edit your
Autoexec.bat
> and add the last line as C:\DOS\NOSMOKE and reboot your computer.
>
> [Customer does this]
>
> Customer:
> It is still smoking.
>
> Service Rep:
> I guess you need to call MicroSoft and ask them for a patch for the
> NOSMOKE.EXE.
>
> [The customer then hung up. We thought that we had heard the last of this
> guy but NO... he calls back four hours later]
>
> Service Rep:
> Hello Sir, how is your computer?
>
> Customer:
> I call MicroSoft and they said that my Power Supply is incompatible with
> their NOSMOKE.EXE and that I need to get a new one. I was wondering when I
> can have that done and how much it will cost...
>
> Moral: Remember those hidden DOS commands!
>
> "Royce" <Royce@discussions.microsoft.com> wrote in message
> news:E07B223E-E274-4F97-807A-2B86753298BA@microsoft.com...
> > i am aware of the quotes and when to use them. correct me if i wrong,
you
> use
> > them when there are spaces in the path. "%Userprofile%\Desktop\test.txt"
> > should work the same as %Userprofile%\Desktop\test.txt and the exit
thing
> is
> > just something i have always done : ) i was unaware of the exit /b vs.
> exit.
> > learn something new everyday. so pegasus when would exit be needed?
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> > > I wasn't even aware of the "Title" command. Good one!
> > > Your code contains a small error. All your redirections should read
> > >
> > > >> "%Userprofile%\Desktop\test.txt"
> > >
> > > i.e. with the surrounding double quotes (which I'm sure you're aware
> of!).
> > > Furthermore, the "exit" command is superfluous.
> > >
> > >
> > > "Royce" <Royce@discussions.microsoft.com> wrote in message
> > > news:43733E19-6F67-4F01-A3EA-7316AAB0C97A@microsoft.com...
> > > > Or this...
> > > >
> > > > @echo off
> > > > title COPYING FILES...
> > > > for /l %%i in (1,1,11) do echo.
> > > > echo Please Wait While Files Are Being Copied...
> > > > echo Started Copying Files On %date% At %time% >>
> > > > %Userprofile%\Desktop\test.txt
> > > > xcopy C:\test G:\backup /e /c /f /h /y >>
> %Userprofile%\Desktop\test.txt
> > > > echo Stopped Copying Files On %date% At %time% >>
> > > > %Userprofile%\Desktop\test.txt
> > > > exit
> > > >
> > > > "George Schneider" wrote:
> > > >
> > > > > I need some help on this one. I want to copy all files from my
> C:\test
> > > to
> > > > > G:\Backup. In addition I want to create a text file that displays
> the
> > > date
> > > > > and time started and date and time finished. I want to script
using
> a
> > > batch
> > > > > file.
> > > > >
> > >
> > >
> > >
>
>