Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: copying dynamic folders to one location...  (Read 2811 times)

0 Members and 1 Guest are viewing this topic.

wildatsun

  • Guest
copying dynamic folders to one location...
« on: June 23, 2009, 09:03:04 AM »
Hi all,

Am running Windows 2003 server.

I use an SFTP service to download mysql dumps to an analysis server, I have no control over the SFTP downloading service.

The data is downloaded daily, each day a new folder with the days date as its name is created and the dumps contained within for downloading -

\2009-06-01\*.bz2
\2009-06-02\*.bz2
\2009-06-03\*.bz2
... etc etc

I sync the data to my server as -

\2009-06-01\*.bz2
\2009-06-02\*.bz2
\2009-06-03\*.bz2
... etc etc
 
Issue is I need to copy the contents of the latest folder I downloaded to a temp location so that it can be extracted and imported into mySQL (all automated).  I can't however work out how to script a copy process (using dos commands as my vbs is very poor) to identify the latest folder using 12hr time parameters to then copy without copying its root folder as well (IE the 2009-06-01 folder that they are saved to on the destination which I don't want).

Can anyone help please, I looked at XCopy but it won't copy the files without creating the folder they originally sat in.  If I can get xcopy to copy folder contents to destination without creating source folder they originally resided in then problem is solved).

Ideally looking for vbs script to identify a folder located in d:\datadumps\.. that was  created within 24hrs and copy its contents to another folder on OS without creating source folder on destination as well.

IE
one day copy -  D:\datadumps\2009-06-01\* to d:\ddextraction\*
next day copy - D:\datadumps\2009-06-02\* to d:\ddextraction\*
etc etc

Many thanks!

gh0std0g74



    Apprentice

    Thanked: 37
    Re: copying dynamic folders to one location...
    « Reply #1 on: June 23, 2009, 06:20:55 PM »
    If you an download GNU findutils, coreutils(see my sig), use the find command to find the latest folder
    Code: [Select]
    c:\test> find_gnu.exe c:\path -type d -mtime -1 | xargs -i cp "{}"  c:\tmp
    the above finds your folder that is 1 day old and copy to c:\tmp