473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

FTP a dynamic file with year and month

6
Do somebody know how to come up with a dynamic file name when ftp it ? I need to download a monthly updated file. The file name appears like datafile_yyyymm.zip where yyyy mean year 2008, and mm mean month 02.
Feb 12 '08 #1
8 10393
Nepomuk
3,112 Expert 2GB
Does somebody know how to come up with a dynamic file name when ftp it ? I need to download a monthly updated file. The file name appears like datafile_yyyymm.zip where yyyy mean year 2008, and mm mean month 02.
Wait, do I understand correctly, you want to download a file once a month, which is called datafile_yyyymm.zip from an FTP-server? And I guess, this should happen automatically? Sounds to me like a batch-script to me... Any experts on that here?

Greetings,
Nepomuk
Feb 13 '08 #2
harshadd
176 100+
NO matter he wants to upload or download a file.
Ddefinetly he wants a dynamic file name to be get created which he can create using my 7 lines below. and set as an DOS environment variable.
copy these three lines in ur .bat or .cmd file. (save as harshad.bat)
note:-
Date command is passed in this bat file to get current system date.
It requires an input from user on console.which is redirected using "<" to an empty file named "enter"

bat/cmd file is as below: harshad.bat

@ECHO OFF
for /f "usebackq delims=/ tokens=3" %%x IN (`date`) do set YYYY=%%x
for /f "usebackq delims=/ tokens=2" %%x IN (`date`) do set MM=%%x
SET FILENAME=DATAFILE_
FOR %%Y IN (%YYYY%) DO SET FILENAME=%FILENAME%%%Y
FOR %%Z IN (%MM%) DO SET FILENAME=%FILENAME%%%Z.ZIP
echo %FILENAME%

to create an emptyfile named "enter" do this on DOS prompt
copy con enter
then press enter key one time to store Carrage Return in the file named "enter"
then press F6 to save file.

when u execute ececute it like this
harshad <enter
and u will have an envirnment variable filename set to your required filename
type SET and check this
tested on XP PRO SP 2

I BET I AM THE MOST POWERFULL MSDOS USER IN ENTIRE MUMBAI ANY ONE WANTs TO CHALLANGE THIS STATEMENT?

HARSHAD.
Feb 13 '08 #3
yfguo
6
thank your reply. I think that works.

Here another question rises due my further investigation on not only downloading a file through ftp, but also through http. do you have any idea how to use NT commands to download a file from a web like http://www.mydomain.com/data/datafile.zip ?

Thanks in advance.
Feb 13 '08 #4
harshadd
176 100+
thank your reply. I think that works.

Here another question rises due my further investigation on not only downloading a file through ftp, but also through http. do you have any idea how to use NT commands to download a file from a web like http://www.mydomain.com/data/datafile.zip ?

Thanks in advance.
If you know the perfect URL of the file , asuming that the only file name will change daily. you can directly put this URL on browser to get the file d/loaded.
optionally u can make VB/VBS script for this... HND
Feb 15 '08 #5
Nepomuk
3,112 Expert 2GB
thank your reply. I think that works.

Here another question rises due my further investigation on not only downloading a file through ftp, but also through http. do you have any idea how to use NT commands to download a file from a web like http://www.mydomain.com/data/datafile.zip ?

Thanks in advance.
To download a file from command line, you can use a program like wget, which originally comes from the *nix area, but was ported to Windows.

You just have to use the command
Expand|Select|Wrap|Line Numbers
  1. wget "http://www.mydomain.com/data/datafile.zip"
to download it.
By the way, wget supports both ftp and http downloads.

Greetings,
Nepomuk
Feb 18 '08 #6
shanaf
1
NO matter he wants to upload or download a file.
Ddefinetly he wants a dynamic file name to be get created which he can create using my 7 lines below. and set as an DOS environment variable.
copy these three lines in ur .bat or .cmd file. (save as harshad.bat)
note:-
Date command is passed in this bat file to get current system date.
It requires an input from user on console.which is redirected using "<" to an empty file named "enter"

bat/cmd file is as below: harshad.bat

@ECHO OFF
for /f "usebackq delims=/ tokens=3" %%x IN (`date`) do set YYYY=%%x
for /f "usebackq delims=/ tokens=2" %%x IN (`date`) do set MM=%%x
SET FILENAME=DATAFILE_
FOR %%Y IN (%YYYY%) DO SET FILENAME=%FILENAME%%%Y
FOR %%Z IN (%MM%) DO SET FILENAME=%FILENAME%%%Z.ZIP
echo %FILENAME%

to create an emptyfile named "enter" do this on DOS prompt
copy con enter
then press enter key one time to store Carrage Return in the file named "enter"
then press F6 to save file.

when u execute ececute it like this
harshad <enter
and u will have an envirnment variable filename set to your required filename
type SET and check this
tested on XP PRO SP 2

I BET I AM THE MOST POWERFULL MSDOS USER IN ENTIRE MUMBAI ANY ONE WANTs TO CHALLANGE THIS STATEMENT?

HARSHAD.

Thanx harshadd, but can you show me how to fetch a dynamic file name like "datafile_ddmmyy.csv" from an ftp location like "ftp://location/folder/datafile_ddmmyy.csv" and save it as "datafile.csv" in the location of the bat script?
Mar 31 '08 #7
harshadd
176 100+
Thanx harshadd, but can you show me how to fetch a dynamic file name like "datafile_ddmmyy.csv" from an ftp location like "ftp://location/folder/datafile_ddmmyy.csv" and save it as "datafile.csv" in the location of the bat script?
Date command from DOS returns o/p like this
C:\>date
The current date is: 31/03/2008
Enter the new date: (dd-mm-yy)
here Year is in YYYY format.
You required in YY format.. its posible but not easy task to get it converted into YY.
Please feedle with FOR command and try to get only 2 digit year as output

FOR /f "usebackq delims=/ tokens=3" %x IN (`date`) do echo %x
Also getting Date is too NOT simple as above commands can give you year(YYYY)
and Month (MM) by changing tokens=2
But tokens=1 do not give date in (DD) form


wait... let me try........
Mar 31 '08 #8
harshadd
176 100+
To get filename dinamically as datafile_ddmmyy.csv use the below .BAT file.
note you have to have your regional setting for this bat file to work properly as
CUSTOM date "/dd/MM/yyy" instead of "dd/MM/yyyy" .
Note that MM is in caps and and an extra "/" is required to work with this bat file.
This is only because I can not resolve Date part of date if date is not starting with "/" Month and year can be resolved as u seen earlier....
Regards HArshad.

///start harshad.bat
@ECHO OFF
for /f "usebackq delims=/ tokens=3" %%x IN (`date`) do set YYYY=%%x
for /f "usebackq delims=/ tokens=2" %%x IN (`date`) do set MM=%%x
for /f "usebackq delims=/ tokens=2" %%x IN (`date`) do set DD=%%x

SET FILENAME=DATAFILE_
FOR %%Y IN (%YYYY%) DO SET FILENAME=%FILENAME%%%Y
FOR %%Z IN (%MM%) DO SET FILENAME=%FILENAME%%%Z
FOR %%X IN (%DD%) DO SET FILENAME=%FILENAME%%%X.csv

echo %FILENAME%
//end harshad.bat

I am working on this to happend without changing regional settings or to change it and reset back onthe fly.
Regards
Harshad
Apr 1 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ken Halley | last post by:
How does one refer to a variable name using a variable within a variable name??? For example, I want to perform a SQL query and use the results of the query to determine which variable to assign a...
1
by: Luis | last post by:
Hi, I am trying to create a stored procedures (SQL 7.0), to provide data in a crosstab format. (I'm using Crystal Reports 8.5, but the Crosstab capabilities are terrible, so I have to do as...
2
by: znelson | last post by:
I'm looking for a way to transform the contents of n source tables into a single destination table. This by itself is no problem. However, the name of the source tables change, so I'll need to...
3
by: Abhas | last post by:
> > Hi, this is Abhas, > > I had made a video library program in C++, but was facing a problem. > > After entering 12 movies, i cannot enter any more movies. > > Something gibberish comes instead....
9
by: Gianni | last post by:
I have to insert in a html select the last 10 years <select name="year" onChange="month()" size=5> <option value="1994">1994</option> <option value="1995">1995</option> <option...
4
by: Robert Camsky | last post by:
Hi, I've got web.sitemap file with few nodes and subnodes and SiteMapPath control. It works fine. But imagine, I'm worrking on an calender implemented this way: calendar.aspx -> showing...
10
by: Paul | last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a server. I have a browse to find the file on the server but need to create the path dynamically as to were it will go...
4
by: tlcvetan158 | last post by:
Hi, I'm a newbie at C++. I am just trying to read a file with three columns of data into arrays and write it back out, to see how arrays work. This runs with no errors, but the output doesn't look...
0
by: miamikk | last post by:
I am XML newbie. I have question about inserting dynamic text in the header of HTML table. This is the site I have created (Only Report Type 1 is working)...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.