473,442 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 10407
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)...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.