473,887 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FTP a dynamic file with year and month

6 New Member
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 10436
Nepomuk
3,112 Recognized Expert Specialist
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 New Member
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=DATAFI LE_
FOR %%Y IN (%YYYY%) DO SET FILENAME=%FILEN AME%%%Y
FOR %%Z IN (%MM%) DO SET FILENAME=%FILEN AME%%%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 New Member
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.co m/data/datafile.zip ?

Thanks in advance.
Feb 13 '08 #4
harshadd
176 New Member
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.co m/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 Recognized Expert Specialist
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.co m/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 New Member
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=DATAFI LE_
FOR %%Y IN (%YYYY%) DO SET FILENAME=%FILEN AME%%%Y
FOR %%Z IN (%MM%) DO SET FILENAME=%FILEN AME%%%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_ddmmy y.csv" from an ftp location like "ftp://location/folder/datafile_ddmmyy .csv" and save it as "datafile.c sv" in the location of the bat script?
Mar 31 '08 #7
harshadd
176 New Member
Thanx harshadd, but can you show me how to fetch a dynamic file name like "datafile_ddmmy y.csv" from an ftp location like "ftp://location/folder/datafile_ddmmyy .csv" and save it as "datafile.c sv" 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 New Member
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=DATAFI LE_
FOR %%Y IN (%YYYY%) DO SET FILENAME=%FILEN AME%%%Y
FOR %%Z IN (%MM%) DO SET FILENAME=%FILEN AME%%%Z
FOR %%X IN (%DD%) DO SET FILENAME=%FILEN AME%%%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
10027
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 value to. Let's say I've dimmed 12 variables based on the months called "featured_x_product" where x is the month. I'd like to refer to the variable with something like: featured_" & R("month") & "_product where R("month") is the from the...
1
5236
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 much as possible on the SQL side) I have a table with the following fields: Year (int)
2
5865
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 base the transform task on a global variable that I can update via external code. Not sure how to do that. I'm ok with executing the package 10 times if there's 10 source tables. The last unknown piece is modifying the query used for the...
3
2717
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. > > Can somebody please tell whats wrong?? > > This is the code : : #include<fstream.h> #include<conio.h>
9
2154
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 value="1996">1996</option> <option value="1997">1997</option> <option value="1998">1998</option> <option value="1999">1999</option> <option value="2000">2000</option>
4
2614
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 upcomming events calendar.apsx?year=2005 showing calendar for year 2005 calendar.apsx?year=2005&month=1 showing january in 2005 calendar.aspx?year=2005&month=1&day=1 showing 1/1/2005
10
2271
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 based on some dropdown boxes, one for the year and one for the month. This line saves the file so I am trying to get the month and year from the dropdown boxes and put them in the month and year variables but this does not work,...
4
42748
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 like the input, so I think I just have something specified incorrectly, but not sure what. My input: 1999 1 3 1999 2 6 1999 4 5 My program:
0
1469
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) http://www.ustrade.fiu.edu/CustomsDistrict_Free.aspx The headers (Commodity Description, HS4, etc.) are static and I would like to add Month value in the Columns 3-6. Instead of "Year Amount($)", I would like to have the column header as "Month Year Amount ($)". Right now the "Year"...
0
9957
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10771
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10877
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10434
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7143
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5810
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4633
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4239
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.