Re: copy/open/move file most most recent datestamp from command li

From: Arran (Arran_at_discussions.microsoft.com)
Date: 10/27/04


Date: Wed, 27 Oct 2004 13:39:06 -0700

Torgeir

thats perfect! works a treat thanks

arran

"Torgeir Bakken (MVP)" wrote:

> Arran wrote:
>
> > I want to be able to perform one or all of the following commands
> > copy/move/open in a directory with multiple files and im only after the most
> > recent one ive looked a xcopy but dont see how i could use it as it needs to
> > be a independent command such that it can be run in a batch file at any date
> > without any input.
> >
> > any ideas
> Hi
>
> Batch file that finds the most recent file and put it into
> the environment variable newest (change C:\my_test to whatever
> folder you want result from):
>
> --------------------8<----------------------
> @echo off
>
> set folder=C:\my_test
>
> for /f "tokens=1 delims=" %%a in ('dir /b /o:d "%folder%"') do set newest=%%a
>
> if not "%newest%"=="" echo Newest file is "%newest%"
> if not "%newest%"=="" echo Full path: "%folder%\%newest%"
>
> --------------------8<----------------------
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>



Relevant Pages

  • Re: script to create a file with unique name
    ... > Or if you are using a batch file, you could use the code below. ... > echo File name: %today%.txt ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windows.server.general)
  • Re: Writing a batch file
    ... Sorry, I can't, VB Scripting is not my area of expertise. ... Paul Randall will respond, or else you could post your question ... by the way thank you so much for your answer about my batch file. ... Prompt commands. ...
    (microsoft.public.windowsxp.general)
  • Re: what kind of scripting is this ?
    ... echo Good morning %name% ... Batch files have nothing in common with VB Scripting. ... is far more powerful than batch file programming. ... A batch file consists of a collection of commands ...
    (microsoft.public.scripting.vbscript)
  • Re: Yikes! Error message 80070424
    ... Worked like a charm Torgeir! ... I have no idea what the commands were but I'm ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windowsupdate)
  • Re: cannot update w2k3 server
    ... > net start cryptsvc ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windowsupdate)