Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

select the newest file in a folder

9 views
Skip to first unread message

Ammammata

unread,
May 27, 2021, 3:27:35 AM5/27/21
to
I'd like to locate the newest file in a backup folder (through a network
path like \\192.168.1.4\backup\server\data), to copy it locally and manage,
packing and sending to a remote FTP

file names are increasing (like yyyymmdd-hhmmss), so if I sort the content,
the newest could be the first or the last

I'd like to do this without too many external tools, using just a packer
like 7zip (or the internal ZIP command available in explorer)

the task will run on windows, version 7, until the pc will be upgraded to
10

thank you

--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
-=- -=- -=- -=- -=- -=- -=- -=- - -=-
........... [ al lavoro ] ...........

Ammammata

unread,
May 27, 2021, 3:34:21 AM5/27/21
to
Il giorno Thu 27 May 2021 09:27:32a, *Ammammata* ha inviato su
alt.msdos.batch il messaggio
news:XnsAD37603B620A7am...@127.0.0.1. Vediamo cosa ha
scritto:

> I'd like to locate the newest file in a folder

I reply to myself :/

for /f %%i in ('dir /b/a-d/od/t:c') do set LAST=%%i
echo The most recently created file is %LAST%

Fin Tres Nueve Dos

unread,
May 28, 2021, 1:41:08 AM5/28/21
to
for /f "tokens=*" %a in ('dir "\\192.168.1.4\backup\server\data\*.*" /b /o-d') do @set LastFile=%~fa

echo %LastFile%




0 new messages