Batch file help needed please!

  Radix Lecti 10:46 24 Nov 2006
Locked

Hi all, I have a batch file here, designed to Auto Archive old files greater than a 60 days.

The script works fine, but for some reason, the output file name is not as I'd expect, and I wondered whether there were any clever bods out there who could point out the reason why.

The section of script I have is as follows:

echo Database.
set physfile="S:\Database.mdb"
set filename="Database"
set fileext="mdb"
set filesrcdir="S:\"
set filedestdir="S:\Backup"
set filedestdirMonthly="S:\Backup2"
call doCompactDB.bat %physfile% >> backupDBFiles.log
call doDailyCopy.bat %filename% %fileext% %filesrcdir% %filedestdir% >> backupDBFiles.log
call doMonthlyCopy.bat %filename% %fileext% %filesrcdir% %filedestdirMonthly% >> backupDBFiles.log

The output filename I'm getting is (for eg.):

Database__YYYY_MM.mdb

I want:

Database_YYYY_MM_DD.mdb



Any ideas where I'm going wrong?

  Radix Lecti 11:25 24 Nov 2006

Doh! Forgot the actual bat (the caller's above).

rem usage doDailyCopy.bat <filename> <file extension> <srcdir> <destdir>
for /f "Tokens=2-4 Delims=/ " %%a in ('date /t') do set dd=%%a&set mm=%%b&set yy=%%c
set backupsuffix=%yy%_%mm%_%dd%
set src=%3\%1.%2
set dest=%4\Copy_Of_%1_%backupsuffix%.%2
echo Performing Backup of
echo Source file : %src%
echo Destination File : %dest%
copy /Y %src% %dest%


Your thoughts would be most welcome!

  scales 15:00 24 Nov 2006

Is this to do with long file names in DOS only allowing 16 characters? Try shortening Database to Data and see if you get the _DD suffix come out.

  Radix Lecti 13:15 27 Nov 2006

Hi. Great thinking. Tested it out, but I'm getting the same results :(

Any other ideas MOST welcome!

  scales 16:09 27 Nov 2006

OK try changing your Tokens from 2-4 to 1-3.
I think your date values are out by one position.

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

50 best online Adobe XD tutorials

iPad Pro 10.5in (2017) review

Comment connecter un MacBook à une TV ?