copying the latest file

March 1, 2011 at 22:28:47
Specs: Windows XP
I have found an old post
Mechanix2Go March 20, 2008 at 14:09:58 Pacific

This should do the confog.sys

::== my2.bat
:: copy latest c:\windows\config.xxx to \config.bat

@echo off

c:
cd \windows

dir /b/o-d config.* > list

> some.d echo n list
>> some.d echo L 105
>> some.d echo e 100 'copy '
>> some.d echo e 10f ' \config.sys'
>> some.d echo rcx
>> some.d echo 1b
>> some.d echo N newcfg.bat
>> some.d echo w
>> some.d echo q

debug < some.d

newcfg.bat


=====================================
If at first you don't succeed, you're about average.

M2


I am trying to use this same function to copy the latest image from some directories into a single location.
I would also like to rename this file.

So far I can create a list in order but I dont know how to grab the top line.

So far
@echo off
dir s/b/o-d *.jpg > list

Any help would be appreciated.


See More: copying the latest file

Report •


#1
March 2, 2011 at 03:58:29
:: ==========================================
::
:: latest.bat Wed 02-03-2011 18:54:36.18
@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir /b/o-d *.jpg') do (
copy %%a d:\mypix\current.jpg
goto :eof
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
March 3, 2011 at 17:22:05
Thanks Mechanix2GO

This nearly does exactly what I need however if I have this batch file in a root folder with folders of image files is it possible to find the latest file from the subdirectories?

If I have this in the same folder as the images it works perfectly.

Many Thanks
MM


Report •

#3
March 3, 2011 at 17:32:11
Hi M2

I have managed to get it closer using

@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir /s/b/o-d *.jpg') do (
copy %%a d:\mypix\current.jpg
goto :eof
)

However it only found the latest file in the 1st folder and I have a few folders.

Many Thanks
MM


Report •

Related Solutions

#4
March 3, 2011 at 22:51:49
Yep

Run this and post output:

:: ==========================================
::
:: TD.bat Fri 04-03-2011 13:49:20.26
@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b') do (
echo.%%~Ta %%~a
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#5
March 10, 2011 at 22:26:27
Hi Mechanix

[IMG]http://i53.tinypic.com/dvo5kp.jpg[/IMG]
http://tinypic.com/r/dvo5kp/7

I had to set a pause in to see what it was doing. It just listed the folders and files in the directory.
In each directory I receive files each day and a new directory is automatically created from the camera. My aim is to create a webpage using the same name for the latest image.

Many Thanks

MM
PS Sorry for the delay I have been very busy. Also I know you are busy but how or where can I learn what all these commands do?


Report •

#6
March 11, 2011 at 01:07:38
So does it boil down to get the newest file from the newest folder?


=====================================
Life is too important to be taken seriously.

M2


Report •

#7
March 12, 2011 at 04:18:42
Hi M2

Yes that is what I need the newest file from the newest folder copied to a specific folder and renamed latest.jpg


Report •

#8
March 13, 2011 at 11:30:00
Post the output of this.

==================================
@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b/s/ad') do (
echo.%%~Ta %%a
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#9
March 16, 2011 at 21:23:30
Hi Mechanix

Output =
[IMG]http://i54.tinypic.com/15q2kxv.jpg[/IMG]
http://tinypic.com/r/15q2kxv/7

Many Thanks

MM


Report •


Ask Question