I am trying to create a folder with current date as the folder-name. Could you please help me with it?
So far I have done the following:
currentDate = System.DateTime.now.ToShortDateString
–Since this returns ‘/’ in date which is not accepted in Windows, I then replace it with ‘-’ character
currentDate = Replace(currentDate,"/","-",)
–Then I concatenate it to the folder location
folderPath = “R:\Test”+currentDate
–After this step, I’ve tried using MkDir but I keep getting a compilation error that “Expression does not create a value”. createFolder argument type is system.object.
createFolder = MkDir(folderPath)
Would appreaciate your help with this.
With help of Studio Activity
Finally use a powershell activity block and use script option. Map FolderPath in script argument mapping window by clicking on setting icon
Save a script with command mkdir $arg and in script path give path where script is saved
Thank you so much for your response. I followed the steps mentioned in your post but I am getting an error that says “Cannot index into a null array.” Please take a look at the screenshot below. I have combined multiple screenshots into one and marked them with red box. Could you please advise and let me know if I did something incorrectly.
Thanks and regards,
I did some research and was able to create a folder with current date using the following PowerShell script. The current date is calculated in the script itself and the folder path can be entered as per requirement. This script also checks if the folder is already created at the folder path.
$folderName = (Get-Date).tostring(“dd-MM-yyyy”)
if (!(Test-Path $Path))
New-Item -itemType Directory -Path E:\Desktop -Name $FolderName
write-host “Folder already exists”
Thanks & Regards,
You need to assign folder path some value before power shell script gets executed.