Name Directory Using Date and Time

Discussion in 'A-Parser Support Forum' started by scrapefun, Aug 4, 2020.

  1. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    Currently I create a result directory for every 2000 queries like this:

    Code:
    [% IF p1.info.success == 1;
               USE Math;
            dir = Math.int(query.num / 2000);
        'test_raw_single/us_' _ dir _ '/' _ query.gl _ '_' _ query.hl _ '_' _ query.id _ '.html';
    END %]
    This will create directories like:

    us_0
    us_1
    us_2
    etc


    How would I create directories using the date and time like:

    YYYY-MM-DD-H-M-S


    I can use the datefile.format() value but that creates a new directory for every query. I want to create a new directory every 2000 queries using the data and time the folder is created.

    Is this or something similar possible?
     
  2. Support

    Support Administrator
    Staff Member A-Parser Enterprise

    Joined:
    Mar 16, 2012
    Messages:
    4,557
    Likes Received:
    2,167
    Try this:
    Code:
    [% USE d = date(format = '%Y-%m-%d-%H-%M-%S', locale = 'C');
    
    IF lines % 2000 == 0;
        dir = d.format();
    END;
    
    lines = lines + 1;
    
    'test_raw_single/us_' _ dir _ '/' _ query.gl _ '_' _ query.hl _ '_' _ query.id _ '.html' %]
     
    scrapefun likes this.
  3. scrapefun

    scrapefun A-Parser Enterprise License
    A-Parser Enterprise

    Joined:
    Feb 24, 2015
    Messages:
    184
    Likes Received:
    34
    Works perfect. Thanks!
     
    Support likes this.

Share This Page