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
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
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
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
===================================== 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:
Summary: I have .sql files with timestamps in a folder like: hddaily 20081130 0600.sql, hddaily 20081129 0600.sql, hddaily 20081130 0600.sql, etc. Filename is “hddaily yyyyMMdd HHmm.sql” Format. I need use...
Summary: Hi, I want a shell script which is used to copy a file from a local drive to unix server. I want to ignore the username and password of local host. please help me!! i am a beginner in shell scripting....
Summary: Not tested. For /l %%1 in (1,1,200) do ( copy message.xml message%%1.xml > nul ) Or: For /l %%1 in (1,1,%1) do ( copy message.xml message%%1.xml > nul ) The first script would copy the file ...