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

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 10/26/04


Date: Tue, 26 Oct 2004 21:59:04 +0200

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: Robocopy - not providing destination in log output
    ... command line tool to be a part of that. ... working script (Batch file) servicing a large ... People who post questions in a *scripting* newsgroup ... Function pad ...
    (microsoft.public.windows.server.scripting)
  • 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: 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: Logs remote ip when connects to exchange, ftp, or remotly to s
    ... I said I was sorry about cross posting I see you took some physcology classes ... I asked a question yes I might not know scripting but I seem to find out how ... server through remote desktop on the desktop of his server it showed the ip ... If you can help me thanks if not then dont take this personal and as ...
    (microsoft.public.windows.server.scripting)
  • Re: Batch commands on Windows
    ... OK, actually on second test, the problem is mostly with IDLE, but not ... # this actually does the same thing as Python, ... then delete the batch file, but that seems like an awful hack. ... And that seems like the most basic thing that a scripting ...
    (comp.lang.python)

Quantcast