web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Folder name date suffi...
Power Automate
Unanswered

Folder name date suffix from JS - Illegal characters in path

(0) ShareShare
ReportReport
Posted on by 8

Hello,

 

I would like to create the PAD flow, which takes current DateTime, converts it to string in format DDMMYYYY_HHMMSS and creates the folder and file which will be using this string as a suffix eg. folder with name "Data created on 03022021_123821" should be created.

PAD contains action for running JS (Run JavaScript), so I used this action to create this suffix. Code below:

 

var curDateTime = new Date();
var dateStringArray = [];

dateStringArray.push((curDateTime.getDate()<10?"0":"")+curDateTime.getDate());
dateStringArray.push((curDateTime.getMonth()+1<10?"0":"")+(curDateTime.getMonth()+1));
dateStringArray.push("" + curDateTime.getFullYear());
dateStringArray.push("_");
dateStringArray.push((curDateTime.getHours()<10?"0":"")+curDateTime.getHours());
dateStringArray.push((curDateTime.getMinutes()<10?"0":"")+curDateTime.getMinutes());
dateStringArray.push((curDateTime.getSeconds()<10?"0":"")+curDateTime.getSeconds());

var dateString = dateStringArray.join('');

WScript.echo(dateString);

 

 

This JS provides correct dateString and is exported from action to JavascriptOutput variable. However when this output is used in actions to create/rename file/folder, an error is displayed. I tried to remove the time and leave just date part of the suffix, but the result is the same:

 

Robin.Core.ActionException: Can't create folder Data created on 03022021
 into C:\Users\powerplatform003\Documents\DUMMY_FI Team. ---> System.ArgumentException: Illegal characters in path.
 at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
 at System.IO.Path.Combine(String path1, String path2)
 at Robin.Modules.Folder.Actions.FolderActions.CreateFolder(Variant newFolderPath, Variant newFolderName, Variant& newFolder)
 --- End of inner exception stack trace ---
 at Robin.Modules.Folder.Actions.CreateFolder.Execute(ActionContext context)
 at Robin.Runtime.Engine.ActionRunner.RunAction(String action, Dictionary`2 inputArguments, Dictionary`2 outputArguments, IActionStatement statement)

 

Now, when we use 03022021 suffix directly (not as a result from JavaScript), the above error is not happening.

Did anybody else have simillar situation?

 

Regards,

ML

I have the same question (0)
  • miketran13 Profile Picture
    720 on at

    Hi,

     

    Can you take more screenshots of your detail actions on PAD? 

     

    And by the way, why do you need to have the JS script to just convert and format the datetime. You can do that with these simple actions in PAD. 

     

    datetime.png

     

    Thanks and hope it can help you. 

    Mike

    ---------------------------------

    Did I answer your question? Please consider to Mark my post as a solution! to guide others

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    You probably figured it out by now, but the issue is that WScript.echo outputs a CRLF at the end of the variable.

  • BI_RPA_Andy Profile Picture
    65 on at

    THANK YOU!  This is the proper answer.  Had a very similar issue running Shell script which was returning a file path that I was using in the 'Read text from file' command that would result in the 'illegal character in path' error.  Simply trimmed the variable and we are in business.  Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 272 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 147 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 146 Super User 2026 Season 2

Last 30 days Overall leaderboard