Computing.Net > Forums > Programming > bat script for copy lastest file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

bat script for copy lastest file

Reply to Message Icon

Name: Shilee
Date: June 26, 2008 at 00:14:53 Pacific
OS: win xp
CPU/Ram: 3.2/512
Product: dell
Comment:

I have .csv files with timestamps in a folder like: 17068679.CSV, 17068678.CSV, 17068668.CSV, 16068679.CSV, 16068678.CSV etc.
I need to know how many lastest files (those files have same timestamp like "17068") in the folder then I can upload them to my ftp server. Any1 can help?
ty before



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: June 26, 2008 at 02:54:03 Pacific
Reply:

If I understand you correctly, you can just do

mput 17068*.csv

on your ftp client.


0

Response Number 2
Name: Shilee
Date: June 26, 2008 at 02:58:41 Pacific
Reply:

I have to do it daily so tmr they will be 18068*.csv so it doesnt work ur this way


0

Response Number 3
Name: Mechanix2Go
Date: June 26, 2008 at 04:20:01 Pacific
Reply:

Didn't we go through this a couple days ago?


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

M2


0

Response Number 4
Name: klint
Date: June 26, 2008 at 04:20:04 Pacific
Reply:

How does 17068 translate to the actual day? Do you have the algorithm that gives you this number, given a day, month and year?


0

Response Number 5
Name: Shilee
Date: June 26, 2008 at 18:46:36 Pacific
Reply:

17068 mean June 17th 2008


0

Related Posts

See More



Response Number 6
Name: klint
Date: June 27, 2008 at 00:44:13 Pacific
Reply:

Use the %DATE% variable to get today's date. On my system, %DATE% is formatted as dd/mm/yyyy. On yours, it may be a different format, so you'll have to adjust the code below accordingly.

set dd=%date:~0,2%
set mm=%date:~3,2%
set y=%date:~9,1%
set filespec=%dd%%mm%%y%*.csv
copy %filespec% ..\other_folder


0

Response Number 7
Name: Mechanix2Go
Date: June 27, 2008 at 01:11:11 Pacific
Reply:

http://www.computing.net/answers/pr...

We been through all this.


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

M2


0

Response Number 8
Name: Shilee
Date: June 27, 2008 at 01:35:05 Pacific
Reply:

@Mechanix2Go yes, i know but my Pro wasnt solved in this topic
ty klint ur script worked well but can u check my script below why it only uploads 1 file to my ftp server

set mm=%date:~4,2%
set dd=%date:~7,2%
set y=%date:~13,1%
set filespec=%dd%%mm%%y%*.csv

@echo off
echo user myysername> ftpcmd.dat
echo mypassword>> ftpcmd.dat
echo bin>> ftpcmd.dat
echo put c:\csv\%filespec%>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat myftpserver
del ftpcmd.dat


0

Response Number 9
Name: klint
Date: June 27, 2008 at 02:05:56 Pacific
Reply:

Use mput (multiple put) instead of put.


0

Response Number 10
Name: Mechanix2Go
Date: June 27, 2008 at 02:21:14 Pacific
Reply:

If you use #8 from the other thread it will copy files to d:\outgoing [modify to suit]

You may want to clear that directoy first.

Then just ftp from there.

I think you'll want MPUT instead of PUT.


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

M2


0

Response Number 11
Name: Shilee
Date: June 29, 2008 at 18:55:11 Pacific
Reply:

I used mput but it didnt work


0

Response Number 12
Name: klint
Date: June 30, 2008 at 14:26:07 Pacific
Reply:

I don't know why mput doesn't work. You could try the following:

1. Check the generated ftpcmd.dat file contains the correct filespec.

2. Adding a line for debugging purposes, just before the mput command:

!dir c:\csv\%filespec%

This should do a dir listing on the local machine, and it should show all the files you expect to be there.

3. Instead of mput c:\csv\%filespec% try splitting it up into two lines:

lcd C:\csv
mput %filespec%

I hope that helps.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: bat script for copy lastest file

script to copy specify date file to www.computing.net/answers/programming/script-to-copy-specify-date-file-to/17662.html

Shell script to copy a file from local drive www.computing.net/answers/programming/shell-script-to-copy-a-file-from-local-drive-/18791.html

Copy a File X number of times www.computing.net/answers/programming/copy-a-file-x-number-of-times/18996.html