Create a new folder in windows explorer with the current date and time

Hi,

Is it possible to create a new folder in windows explorer with the current date and time, in the reordered format of YYYY.MM.DD hh.mm.ss. (as appose to DD/MM/YYYY hh:mm:ss).

I’ve almost solved the date and time text string, which will form the new folder’s name - I just need to reorder the date format by swapping the positions of the DD with YYYY. (See attached image)

I’m not sure how to do the folder creation part though. Is there a node which can create a new folder in windows explorer? Or would I need to create a custom code block?

Thanks for any help in advance.

1 Like

Have a look at the DateTime.Components node …

2 Likes

Thanks Andreas_Dieckmann! That’s solved my first issue and made the process of extracting elements from the current date and time a lot easier. I just need a solution for the folder creation part now.

@Mark_246

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

import os

dirpath = IN[0]
dirname = IN[1]
os.makedirs(dirpath + "\\" + dirname)
2 Likes

dt=DSCore.DateTime.Components(DSCore.DateTime.Now);
pth=a+dt["day"]+"."+dt["month"]+"."+dt["year"]+"."
+dt["hour"]+"."+dt["minute"]+"."+dt["second"];
2 Likes

How can I get e.g. F:\29.08.2016 18.18.57 ? Otherwise the folder will not sort properly by name

…+".0"+dt[“month”]+…

but will that work in october-december?

1 Like

@Thomas_Vogt1 A better way…

dt=DSCore.DateTime.Components(DSCore.DateTime.Now);
pth=a+String.PadLeft(dt["day"]+"",2,"0")
+"."+String.PadLeft(dt["month"]+"",2,"0")
+"."+String.PadLeft(dt["year"]+"",2,"0")
+"."+String.PadLeft(dt["hour"]+"",2,"0")
+"."+String.PadLeft(dt["minute"]+"",2,"0")
+"."+String.PadLeft(dt["second"]+"",2,"0");
4 Likes

3 posts were split to a new topic: Add multiple folders from Excel sheet