views:

32

answers:

1

I recently had very kind assistance on how to make the below code copy the most recent file from a file on my C:\ called 'C:! BATCH'

It's transpired that I now need to have the batch file only look for .bak files in this dorectory, and while I'm positive this is a relatively simple tweak, I've so far had no luck on finding how this is done.

Any advice on this would be very much appreciated, many thanks!

@echo off
pushd C:\! BATCH
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%G in ('dir/b/od') do (set newest=%%G)
copy "!newest!" C:\DROP\
PAUSE
A: 

I now need to have the batch file only look for .bak files in this directory.

The change is simply adding *.bak to the dir command.

@echo off

pushd c:\BATCH\

setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%G in ('dir/b/od *.bak') do (set newest=%%G)

copy "!newest!" c:\DROP\look for .bak files in this dorectory
smink
Perfect, thankyou so much!
david.murtagh.keltie.com