PC Review


Reply
Thread Tools Rate Thread

.bat file to copy files using current date as part of name?

 
 
+Bob+
Guest
Posts: n/a
 
      20th Oct 2008
I need to set up a bat file that will use xcopy to copy a directory
from one drive to another. The resulting directory needs to
incorporate the date that it is copied into the name. Something like
this:

xcopy c:\bigdir\*.*/s/e d:\bigdir-10-oct-2008\*.*

I need to do this on a regular basis, so how can I pull the date
within the bat file into a variable?

Also, assuming I can get the date into a variable named something like
"DateIn" will a command like this work:

xcopy c:\bigdir\*.*/s/e d:\bigdir-%DateIn%\*.*

Thanks,
 
Reply With Quote
 
 
 
 
+Bob+
Guest
Posts: n/a
 
      29th Oct 2008
On Mon, 20 Oct 2008 11:28:59 -0700, Ray Parrish <(E-Mail Removed)> wrote:

>Another link offers the following code which is similar to the last link
>there -
>
>for /f "tokens=2-4 delims=/ " %%i in ('date/t') do (
> (set Dy=%%i)
> (set Mth=%%j)
> (set Yr=%%k)
>)
>I've modified the last line of his code below to show how to name your
>directory.
>
>mkdir c:\%Dy%-%Mth%-%Yr%
>
>This assumes you want it on the C drive, change the drive and pathname
>to what you need.


Thanks Boys, this got me where I needed to go.


>
>Later, Ray Parrish


 
Reply With Quote
 
+Bob+
Guest
Posts: n/a
 
      29th Oct 2008
On Mon, 20 Oct 2008 09:53:51 -0700, "Terry R." <(E-Mail Removed)>
wrote:

>for /f "tokens=1" %%a in (
> 'cscript.exe //Nologo %tmp%\today.vbs') do set today=%%a


Terry:

It seems to throw an error on this line. I don't know enough about
windows scripting to diagnose it.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: .bat file to copy files using current date as part of name? Terry R. Windows XP General 0 29th Oct 2008 02:23 PM
Copy Paste a file into a folder with the current date casan.mike@gmail.com Microsoft Excel Programming 1 28th Oct 2008 04:39 PM
Re: .bat file to copy files using current date as part of name? Ray Parrish Windows XP General 0 20th Oct 2008 07:28 PM
Re: .bat file to copy files using current date as part of name? Terry R. Windows XP General 0 20th Oct 2008 05:53 PM
showing current date as part of file name Leslie Microsoft Excel Programming 2 10th Apr 2004 08:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:26 AM.