[<<]Message[>>]    [<<]Author[>>]    [<<]Subject[>>]    [<<]Thread[>>]

Number : 4409 Date : 2003-04-22 Author : Garry Deane Subject : Re: Date Macro Size(KB) : 1
--- In xxcopy@yahoogroups.com, "dcohn99" wrote: > Yan - > > I need some help (or anyone that has a clue). > > I am using the Data Macro to create directory names while > copying files. It happens to be that the application we > are copying files using the following format for the > folder names. > > 4-21-03 or 11-22-03 etc. The key issue here is the > padded zeros that XXcopy performs. > > This is because we also copy the directories that the system > creates. Those folders are in the format 4-2-03. Therefore > if I have no way to remove those padded zeroes I end up > getting duplicate files. > > Any ideas on how to fix this issue. Renaming the directories > is not a choice as all of this is automated and we cannot > babysit the process. As has been said elsewhere, this date format is pretty silly. However assuming you have no control over the application that produces those dates, you might be able to use xxcopy to calculate yesterday's date then massage the result to strip the leading zeroes. You don't state which OS this runs under. If you are using NT/W2k/XP it is fairly straightforward to parse the output from a "non-action" Xxcopy command to get the date macro result, strip the leading zeroes from the day and month components then issue the actual Xxcopy command using these values. You would need a utility program to do the same thing in W9x/ME. Here's an example. @echo off setlocal :: This next is all 1 line - it is better if c:\dummy does NOT exist :: It gets the single line which has the expanded date macro set "cmd=xxcopy c:\dummy\ f:\/$mm-dd-yy$\ /tm-1/L/ec^|find /i "/L/ec"^|find /v "$"" :: extract the values for mm, dd and yy for /f "tokens=4-6 delims=\-" %%a in ('%cmd%') do ( set mm=%%a&set dd=%%b&set yy=%%c) :: strip leading zeroes from mm & dd set /a mm=1%mm%-100, dd=1%dd%-100 :: issue your xxcopy command (or whatever) using non-leading :: zero values for mm and dd echo yesterday was %mm%-%dd%-%yy% Garry
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.