Auto download - filename UCC-YYYYMMDD.zip format.

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Auto download - filename UCC-YYYYMMDD.zip format.
# 1  
Old 08-16-2010
Auto download - filename UCC-YYYYMMDD.zip format.

Hi,

On a daily basis I have download .zip file from FTP site. Naming convention of .zip is UCC-20100816.zip

I want to create windows batch file which will automatically download latest .zip file based on system date.

.zip file is gets uploaded on a daily basis on FTP site in UCC-YYYYMMDD.zip format.

Plz suggest.

Thankx,
Rahul Bahulekar.
# 2  
Old 08-16-2010
You're in luck, I've had to do something similar in the last week. I found the date code on the net a while ago, I forget where.

Code:
SET currdate=%date%
SET mm=%currdate:~4,2%
SET dd=%currdate:~7,2%
SET yyyy=%currdate:~10,4%
SET filename=UCC-%yyyy%%mm%%dd%.zip

wget ftp://sitename/path/to/%filename%

You can get wget for windows here.

Last edited by Corona688; 08-16-2010 at 06:53 PM..
# 3  
Old 08-17-2010
Generating YYYYMMDD depends on the reply to the MSDOS "date" command.
Mine replies "DD/MM/YYYY" (10 characters).

Generating the date on a UK Windows PC or Server in a MSDOS batch file.

Code:
@echo off
REM Format of date is DD/MM/YYYY
SET currdate=%date%
SET dd=%currdate:~0,2%
SET mm=%currdate:~3,2%
SET yyyy=%currdate:~6,4%
SET yyyymmdd=%yyyy%%mm%%dd%
echo %yyyymmdd%

20100817



You can also drive Microsoft FTP in a Windows Batch File. Whatever you type for your daily download session (including username and password) can be done from a Windows Batch File.

Last edited by methyl; 08-17-2010 at 09:04 AM..
# 4  
Old 08-17-2010
Quote:
Originally Posted by methyl
Generating YYYYMMDD depends on the reply to the MSDOS "date" command.
Thank you for pointing out that its output differs by region! Actually though, it depends on the %date% builtin, which is not a command. </nitpick>
# 5  
Old 08-20-2010
Thank you for help!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to conver YYYYMMDD to MJD format?

I would like to convert YYYYMMDD to MJD format for eg 20041223 converted to 53362 in MJD format i got logic from javascript to covert it to MJD which is long enough function YMDtoMJD (year, month, day) { var year; var monthi var day; var yr = Math.floor (year); ... (1 Reply)
Discussion started by: mandalmanas24
1 Replies

2. UNIX for Dummies Questions & Answers

Print/cut/grep/sed/ date yyyymmdd on the filename only.

I have this filename "RBD_EXTRACT_a3468_d20131118.tar.gz" and I would like print out the "yyyymmdd" only. I use this command below, but if different command like cut or print....etc. Thanks ls RBD_EXTRACT* | sed 's/.*\(........\).tar.gz$/\1/' > test.txt (9 Replies)
Discussion started by: dotran
9 Replies

3. Shell Programming and Scripting

Date format to be changed from DDMMYYYY to YYYYMMDD

My requirement is:- there will be files at a location each day with the date format DDMMYYYY. Novawise_Activity_Call_Notes_04022013.txt Novawise_Activity_Inbound_04022013.txt Novawise_Activity_Inbound_05022013.txt Novawise_Activity_Call_Notes_05022013.txt... (8 Replies)
Discussion started by: djrulz123
8 Replies

4. Solaris

Date after 5 dates in YYYYMMDD format

Hi Experts, How to get date 5 days after current date in YYYYMMDD format? How do we compare date in YYYYMMDD format? Thanks (1 Reply)
Discussion started by: needyourhelp10
1 Replies

5. Shell Programming and Scripting

Change the date format from mmddyyyy to yyyymmdd

How do I change the date format from mmddyyyy to yyyymmdd in PERL. Can any one help me please. (3 Replies)
Discussion started by: thankful123
3 Replies

6. Shell Programming and Scripting

Find the next day from 20100303 (YYYYMMDD format)

Hi , i have doubt in bash shell script.. for example my file name is sampledate.sh given command = ./sampledate.sh -d 20100303 -f karthi how to find the next day from 20100303 (YYYYMMDD format) After getting the next day ,changed date and -f argument value will be sent to one java class. ... (13 Replies)
Discussion started by: karthinvk
13 Replies

7. UNIX for Dummies Questions & Answers

Format date from MM/DD/YYYY to YYYYMMDD

I have a file with some date columns in MM/DD/YYYY format: SMPBR|DUP-DO NOT USE|NEW YORK||16105|BA5270715|6/6/2007 |MWERNER|109||||JOHN||SMITH|MD|72211118||||||74559|21 WILMINGTON RD||D|11/6/2003|SL# MD CONTACT-LIZ RICHARDS|||0|Y|N||1411458| And I want to convert the date format to: ... (5 Replies)
Discussion started by: ChicagoBlues
5 Replies

8. Shell Programming and Scripting

get yesterday in yyyymmdd format

how can i get yesterday in yyyymmdd format? :confused: (13 Replies)
Discussion started by: aaron_fong
13 Replies

9. HP-UX

How can i get the yesterday's date in YYYYMMDD format

How can i get the yesterday's date in YYYYMMDD format??? (4 Replies)
Discussion started by: prasadsr
4 Replies

10. UNIX for Dummies Questions & Answers

get yesterday date in yyyymmdd format

I would like to know how I could get a yesterday date in yyyymmdd e.g. today is 20011109, and I would like to get 20011108. Thank you!:confused: (2 Replies)
Discussion started by: hk_newbie
2 Replies
Login or Register to Ask a Question