Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

unzip file (.gz) with date in name and copy to folder

I'm not a programmer by any means, but have a server with an ftp process that runs on a daily basis.
i have a folder named C:\..\Daily that saves files in the following format:

YYYYMMDD_filename.csv.gz

There is a file that gets created every day.

I would like to write a script (in whatever way is possible) that will extract this (and only this file) based on the date and then copy it to a share that exists on a different server  (\\servername\Export)  retaining the filename (with date).

I'm in need of this pretty quickly so if there is anything missing let me know.!

thanks
0
bwllc
Asked:
bwllc
  • 6
  • 5
  • 3
1 Solution
 
AxterCommented:
I recommend you use PHP for this
0
 
bwllcAuthor Commented:
am open for anything
0
 
AxterCommented:
I recommend you post this question in the PHP topic area.
http://www.experts-exchange.com/Web/Web_Languages/PHP/

You have a much better chance of getting a quick and complete answer.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
bwllcAuthor Commented:
If i go the PHP route... I would have to install PHP modules on that server correct? (does this mean i have to install a web server as well? )


0
 
AxterCommented:
>>If i go the PHP route... I would have to install PHP modules on that server correct? (does this mean i have to install a web server as well? )

I'm sorry, but I misunderstood your question.  I thought this file was already on a web server.

I wouldn't use PHP for this.

What is your OS?
0
 
bwllcAuthor Commented:
Windows 2003 Server
0
 
HonorGodCommented:
You could create the following batch file, then schedule it to run once a day.

------------------------------ CopyFile.bat ----------------------------------------
@echo off
 setlocal
 net use r: \\servername\Export password /user:username
 chdir /d C:\...\Daily
 set today=%date:~10,2%%date:~4,2%%date:~7,2%
 copy %today%*.gz r: /v
 net use r: /delete
 endlocal
---------------------------------------------------------------------------------------
0
 
bwllcAuthor Commented:
getting close...
i ran the batch script and this is the output i received:
***********OUTPUT************
200518*.gz
The system cannot find the file specified.
        0 file(s) copied.
r: was deleted successfully.
**************END************

it's not picking up the file name and it seems like it is trying to look for the actual '*' character.

0
 
HonorGodCommented:
It also looks like I mistyped the "year" portion.... sorry.  That part should be

%date:~10,4%
length ------^    

So the set should be:

set today=%date:~10,4%%date:~4,2%%date:~7,2%

sorry about that
0
 
HonorGodCommented:
To get rid of the "r: was deleted successfully." message, make the statement:

net use r: /delete >nul: 2>&1

This sends any messages generated by the "net use" command to the bit bucket.
0
 
bwllcAuthor Commented:
there appears to be an issue with the wildcard functionality of the script.
here is the output:


*********OUTPUT************
The command completed successfully.

20060518*.gz
The system cannot find the file specified.
        0 file(s) copied.
***************************

appreciate all the help!
0
 
HonorGodCommented:
What does your Daily directory contain?

Please execute the following commands, and provide the results

1. What is the actual path to your Daily directory?
    Above, you show it as "C:\...\Daily", hopefully, you provide the actual path correctly.

2. "change to the Daily directory using"  chdir /d C:\...\Daily

3. "list the contents" using "dir"

Thanks
0
 
bwllcAuthor Commented:
the directory has a bunch of files that are listed with the date_FILENAME.csv.gz

I modified the script to contain FILENAME instead of *  that works

now i have to decompress the file on the remote location

i am toying with gunzip "filename"
0
 
HonorGodCommented:
ok.  Sounds good
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now