On Friday, July 13, 2012 4:27:43 PM UTC-4, Todd Vargo wrote:
> On 7/13/2012 1:04 PM, Leon Sharp wrote:
> > On Monday, July 9, 2012 12:26:33 AM UTC-4, foxidrive wrote:
> >> On Monday 09/07/2012 08:36, Todd Vargo wrote:
> >>
> >> > BTW, look at the code you posted again. Although OP wanted to COPY the
> >> > file to another location, the original file should be MOVEd or deleted.
> >>
> >> Deleted after FTP I expect.
> >>
> >> > If you do not remove the file from the original location, the loop will
> >> > copy/ftp the same file indefinitely, not only wasting cpu time, but
> >> > internet bandwidth as well.
> >>
> >> Good point and well spotted. :)
> >>
> >>
> >>
> >> --
> >> Mic
> >
> > Quick question, firstly batch is running great I made some modifications with help from the community and beyond. One thing I need assistance in, I added a date and time stamp at the end of my file for backup. So here lies my issue I am using this:
> >
> > set DateTime=%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~-11,2%%time:~-8,2%
> > COPY /Y "%fname%" "%targetpath%%file%%DateTime%.txt"
> >
> > results log07132012 119.txt (space in between time and date!)
> >
> > Though I am getting the results date and time, when time is less than 10 a leading space is inserted. What am I doing wrong or need to do to the above to have it with a leading 0 instead??
>
> Add the following after your SET command to replace the space with a zero.
>
> set "datetime=%datetime: =0%"
>
> BTW, your SET command will be fine as long as it does not get run near
> midnight or DST change. If you do need to run near these date/time
> changes, the accepted safe practice is to first store date/time into
> variables and then operate on the stored variables.
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)
Thanks Todd So I should do this??
set DateTime=%date:~-10,2%%date:~-7,2%%date:~-4,4%_%time:~-11,2%%time:~-8,2%
set "datetime=%datetime: =0%"
COPY /Y "%fname%" "%targetpath%%file%%DateTime%.txt"
Thanks again, enjoy your weekend.