in reply to Re: Need time Stamp for folder..
in thread Relative Paths...

Thanks.. now i am able create a new file with Name and Date.. but when i run again its not showing folder with same name created at the same time.. am using Windows 7 machine.. Thanks in Advance.

Replies are listed 'Best First'.
Re^3: Need time Stamp for folder..
by AppleFritter (Vicar) on Aug 12, 2014 at 09:36 UTC

    now i am able create a new file with Name and Date.. but when i run again its not showing folder with same name created at the same time.. am using Windows 7 machine..

    I'm not sure what you mean. Can you clarify what the expected and actual results are? E.g. "I'm using your snippet from Re: Need time Stamp for folder... The first time I run it, it does FOO; the second time, I expected it to do BAR, but it actually did BAZ".

    I'm guessing that what's happening is that no new folder is being created the second time. The reason for that is simple: the folder name, e.g. "man 2014-08-12", only changes when the date changes, so running the script twice on the same day will not create another folder (since, naturally, there cannot be two folders with the same name in the same parent folder).

    And it's creating folder names like that because that's what the strftime flags tell it to: "%Y" is the current year (four digits), "%m" is the current month (two digits), and "%d" is the current day (two digits). If you want a finer-grained time stamp, simply adjust the format string for strftime and add more flags, as necessary/desired.

    Have you read up on strftime's flags, as I suggested above?

    Here's Microsoft's documentation for the function. For a finer-grained timestamp, you may want to use something "%Y-%m-%d %H-%M-%S" (which will produce e.g. "2014-08-12 08:28:45"), though I'll caution that this is still granular down to one second.

    If you need to be able to (possibly) create more than one directory per second, you could use a module like Time::HiRes that provides micro- or nanosecond time. But then, this might be an example of an XY Problem, and instead of using timestamps to try and ensure that folder names are unique, you may be better off using another module that guarantees unique names.

    File::Temp has a tempdir function for that purpose, for instance. And although it's intended for temporary directories, they're not automatically deleted, so the module should be suitable for this purpose:

    This is the recommended interface for creation of temporary directories. By default the directory will not be removed on exit (that is, it won't be temporary; this behaviour can not be changed because of issues with backwards compatibility).

    There may well be other useful modules as well.

Re^3: Need time Stamp for folder..
by Anonymous Monk on Aug 12, 2014 at 06:50 UTC

    Thanks.. now i am able create a new file with Name and Date.. but when i run again its not showing folder with same name created at the same time.. am using Windows 7 machine.. Thanks in Advance.

    What is it showing then? How are you checking?

      Folder with date and time is coming... Actually "The destination folder should be in C DRIVE (top level path) and should be timestamped so that every new execution creates a separate PATH".

        Folder with date and time is coming... Actually "The destination folder should be in C DRIVE (top level path) and should be timestamped so that every new execution creates a separate PATH".

        What does that mean? Which question does that statement answer?

      hi Monks.. got solution .. just concatinate Mkdir with localtime..

        Remember Re^2: Need time Stamp for folder..? Where you say it works but then it doesn't do everything you want? You're not explaining how what it does is different from what you want

        Have you followed the links in Re: Need time Stamp for folder.. and read the documentation ? Here is another, strftime

        Does that help?

        and no notifications come to my mail when some 1 replys after doing setting ..

        IIRC, there are no "mail" "notification", only chatterbox, see PerlMonks FAQ