PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?QXJyYW4=?=
Guest
Posts: n/a
 
      26th Oct 2004
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

arran
 
Reply With Quote
 
 
 
 
Torgeir Bakken \(MVP\)
Guest
Posts: n/a
 
      26th Oct 2004
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/scr...r/default.mspx
 
Reply With Quote
 
=?Utf-8?B?QXJyYW4=?=
Guest
Posts: n/a
 
      27th Oct 2004
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/scr...r/default.mspx
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command line file copy to DVD in XP? =?Utf-8?B?Q2hhcmxpZQ==?= Windows XP Hardware 6 2nd Aug 2007 12:22 AM
Copy local file to Network computer by command line =?Utf-8?B?VGhhbmF3YXQ=?= Windows XP Help 1 21st Jun 2006 06:17 AM
Req. freeware command line file search and copy. TIA roadster3043 Freeware 2 16th Oct 2005 02:49 PM
copy a file to the clipboard from the command line Matthew Henry Freeware 16 18th Mar 2004 04:38 PM
Command line utility to copy a file to multiple disks Freeware 3 8th Nov 2003 09:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:31 AM.