@echo off
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set DATE=%%A-%%B-%%C
set bkpdir=c:\win_bak\
set where="%bkpdir%wincmd_%date%.ini"
xcopy "d:\Downloads\WinCmd 32 5.50\wincmd.ini" %where% /q /i /-y
I'm not quite sure if it is politically correct but it gives me a filename like this:
wincmd_11-28-2003.ini
The only problem I am still having is that it asks me if it is a file or directorty I am making when I run the batch file.
I don't understand exactly what it is they are doing here, but it's working, anyway. Thank for all of your help and getting me this far. I owe you one.
@Coco:
I finally got it (for anyone else who is interested, also). This will copy the backups and put a date AND time in the filename. And since I am using COPY instead of XCOPY, there is no need to put the /y parameter on it because COPY will do it automatically as long as it is called from within a batch file.
@echo off
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set mmddyyyy=%%i-%%j-%%k
echo Date: %mmddyyyy%
for /F "tokens=1-2 delims=: " %%l in ('time /t') do set hhmm=%%l%%m
echo Time: %hhmm%
rem -- or use both
echo %mmddyyyy%_%hhmm%
rem -- here is the copy command with the date and time appended
Copy "d:\Downloads\WinCmd 32 5.50\wincmd.ini" "d:\Downloads\WinCmd 32 5.50\Backup\wincmd_%mmddyyyy%_%hhmm%.ini"
Copy "d:\Downloads\WinCmd 32 5.50\Wcx_ftp.ini" "d:\Downloads\WinCmd 32 5.50\Backup\Wcx_ftp_%mmddyyyy%_%hhmm%.ini"
Cool I did know about this for replacing the / by -.
In fact you don't need to use the xcopy just use a simple copy and it will also work without the last question.
@echo off
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set DATE=%%A-%%B-%%C
set bkpdir=c:\win_bak\
set where="%bkpdir%wincmd_%date%.ini"
copy "d:\Downloads\WinCmd 32 5.50\wincmd.ini" %where% -y
If you want to create more file per day you can also modify this to add the time in the name ....
If I try and select two files in the source directory:
"drafts" and "important"
I get:
Copy (2) files to
C:\temp\*.* - (I Edit to read "C:\temp\old_*.*)
And the resulting target files are:
"old_rtant" and "old_ts"
regards:cptjlddavis
If the filenames you wish to copy do not have an extension (as in your example above), how about just copy/renaming to *.old. If they do have an extension then *.*.old will also work.
Boofo wrote:
Now all I got to figure out is how to get this to run automatically once a day. I can do it manually for the other times if I need to.
You have different option for this.
- Schedule it.
- Add the program at the startup. (easiest way is to put it (or a link) in the startup folder in the start menu.)