How to copy the first file in any directory starting with .rar extension?
Define what first ?
Murtaza RC
2009-07-07 21:15:37
does not matter any sorting is fine.
Murtaza RC
2009-07-07 21:16:14
He is asking what you mean by "First". First file when they are sorted by date? or first when sorted alphabetically?
John T
2009-07-07 21:16:32
As I mentioned the order does not matter.
Murtaza RC
2009-07-07 21:17:17
+4
A:
This will copy "the first .rar" file found" (randomly selected, for all I know) in the current folder to C:\Temp. I'd consider this to be a template you can start with.
@ECHO OFF
CLS
FOR %%A in (*.rar) do (
COPY %%A C:\temp
GOTO :Exit
)
:Exit
Philip Kelley
2009-07-07 21:46:57
Technically, it is not random. However, since (with this particular script) we have no real control over what file is the first file listed by the OS, we can assume nothing about which file will be the first returned, so it might as well be random.
Philip Kelley
2009-07-08 13:44:27