find newest file then send to ftp

April 4, 2009 at 15:47:56
Specs: Windows XP
I need a send a daily backup file to ftp site. Is there a way to make a bat file that finds the newest file in directory then send to FTP site?


Thanks!

RM


See More: find newest file then send to ftp

Report •


#1
April 4, 2009 at 16:07:40
@echo off & setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%a in ('dir/b/a-d/od') do (
set latest=%%a
)

> #.ftp echo o mysite.com
>> #.ftp echo username
>> #.ftp echo password
>> #.ftp echo bin
>> #.ftp echo put !latest!
>> #.ftp echo bye

ftp -s:#.ftp


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

M2


Report •

#2
April 4, 2009 at 16:26:06
thanks for the quick response.

I set my login creds for the ftp, but I am getting a "maximum setlocal recursion level reache" response.

regards,

RM


Report •

#3
April 4, 2009 at 16:34:26
lemme guess...

what did you call the script?


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

M2


Report •

Related Solutions

#4
April 4, 2009 at 16:40:49
ftp.bat?

I am clueless with this.....


Thanks!


Report •

#5
April 4, 2009 at 16:44:23
try latest.bat


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

M2


Report •

#6
April 4, 2009 at 16:54:34
lol....

It works but it sent the bat file.........

the bat file is being run from the folder with files I want to send.

RM


Report •

#7
April 5, 2009 at 00:17:58
Put it somewhere else and tell it where the los are.

================================
@echo off & setLocal EnableDelayedExpansion

for /f "tokens=* delims=" %%a in ('dir/b/a-d/od d:\mylogs') do (
set latest=%%a
)

> #.ftp echo o mysite.com
>> #.ftp echo username
>> #.ftp echo password
>> #.ftp echo bin
>> #.ftp echo put !latest!
>> #.ftp echo bye

ftp -s:#.ftp


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

M2


Report •


Ask Question