Script to create folder with time stamp and then move into folder

Discussion in 'Scripting' started by Jim Kiddoo, Dec 3, 2007.

  1. Jim Kiddoo

    Jim Kiddoo Guest

    Hello,
    I am trying to script something to creat a folder with the time and date
    inthe name and then copy files into it. I have a set of files i want copies
    of every hour. Due to the way the app was created the files do not appear to
    change since they take a certain size to satrt and then data is appended to
    them so the size does nto change. Backup sees that they didnt change so
    doesnt back them up again.

    Any help would be apreciated. I have found an applicaiton to create the
    folder with the time and date, but i cant figure out how to copy into that
    folder dynamically. I need to bring the name of the folder created by the
    app into a copy command. I can redirect the output of the create into a txt
    file but how do I read from that to copy into the folder.
    Thanks
    Jim
     
    Jim Kiddoo, Dec 3, 2007
    #1
    1. Advertisements

  2. What you require is not hard to achieve but you need to give
    a detailed example to illustrate your needs.
     
    Pegasus \(MVP\), Dec 3, 2007
    #2
    1. Advertisements

  3. Jim Kiddoo

    Jim Kiddoo Guest

    I need to copy around 50 files into a new directory that is stamped with the
    current time and date. This needs to be scheduled through the scheduler, so
    it has to be scripted to run hourly.

    so every hour a new folder is created with a new name and all the files from
    the main directory are copied into it. This needs to happen every hour with
    a unique folder name every time.

    Thanks for any help.
    Jim
     
    Jim Kiddoo, Dec 3, 2007
    #3
  4. Try this:

    @echo off
    set T=%time:~0,5%
    set dir=%date:/=-% %T::=-%
    echo The target folder is "%dir%".
    xcopy /s /c /y "E:\Main Directory\*.*" "D:\Backup\%dir%\"
     
    Pegasus \(MVP\), Dec 4, 2007
    #4
  5. Jim Kiddoo

    Jim Kiddoo Guest

    That works Perfectly, thank you very much.

    Jim
     
    Jim Kiddoo, Dec 4, 2007
    #5
  6. Thanks for the feedback.


     
    Pegasus \(MVP\), Dec 5, 2007
    #6
  7. It is not possible to filter out the day under DOS.
    However, you can remove it in a Command Prompt
    under Win2000/XP:

    set MyDate=%date:~4%
    echo Date=%MyDate%
     
    Pegasus \(MVP\), Dec 18, 2007
    #7
  8. Jim Kiddoo

    adityajain22 Guest

    Thnx for the script, it worked perfectly,

    I also need to delete the folder which are 24 hours old crated above.

    Thnax
     
    adityajain22, Jan 25, 2014
    #8
  9. Jim Kiddoo

    naved.gmx Guest

    Hello Sir.

    Thanks for your help, I just used the script but the files and folders were copied normally. There were no time / date stamps in the folder.

    is there any changes to be made in command line of %dir% .

    Please advise.

    Thanks a ton.
     
    naved.gmx, Mar 10, 2014
    #9
  10. Jim Kiddoo

    Hot-Text Guest

    | Hello Sir.
    | Thanks for your help, I just used the script but the files and folders
    were copied normally.
    | There were no time / date stamps in the folder.
    | is there any changes to be made in command line of %dir% .
    | Please advise.


    For no one here to help you out
    For Microsoft Move to Online Forums

    Go to the online Forums at:
    < http://social.technet.microsoft.com/Forums/windowsserver/en-US/home >
    If you already sign in to a Windows PC, tablet, or phone, Xbox Live,
    Outlook.com,
    or OneDrive, use that account to sign in.

    If you do not have outlook go here
    Free at: < https://signup.live.com/signup.aspx?lic=1 >

    | Thanks a ton.

    Here how i do it

    Right Hand Click in the folder
    Click Properties
    The date Time stamps will be the day Created

    Look like this:
    C:\WWW\MyNews\TEMP\PJ
    Cleated: Monday, My 15, 2014, 10:42:18 PM

    Right Hand Click on a file in the folder
    Click Properties
    The date Time stamps will be the day Created and Modified

    Look like this:
    C:\WWW\MyNews\TEMP\PJ\Test.txt
    Cleated: Monday, My 15, 2014, 10:42:18 PM
    Modidfed: Monday, My 15, 2014, 10:42:18 PM
    Accessed: Today, May 15, 2014, 10:49:35 PM

    For the Accessed is the time that you
    Right Hand Click it and open
    the Properties to look at the file

    You welcome
    Here a good day!
     
    Hot-Text, May 16, 2014
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.