We have a integration requirement to move files from one folder to another in SharePoint Online. The new file name in the destination folder needs to be suffixed with the current datetime. For instance, if the source filename is Myfile.csv, it should be moved with the new name Myfile_2021-04-15T15:39:23.csv to the destination folder.
Using the Logic App SharePoint Move file action, I haven't been able to achieve this
If another file is already there is an enum and I'm unable to provide a custom expression for it. Further, with this option files are only renamed if there's a file with the same name already existing in the destination folder. Whereas our requirement is to attach datetime to all files that are being transferred, independent whether the file already exist in the destination folder or not.
How can I best achieve this?
Thanks in advance for any assistance.
Since the "Move file" action doesn't provide a feature for us to specify the new file name, I think the requirement can't be implemented by this action. You can just use other action to do it.
For example, use "Get file content" action to get the file content.
Then use "Create file" action to create the new file in the location which you want.
You can specify a name which you want in the "File name" input box.
By the way, the "Get file content" action doesn't provide an expression of file name for us to use in second step. But I noticed that you have got Full path in your description, so you can substring the Full path to get the original file name. And then use utcNow() method to get the current date and append it to file name.
Related
I have created a logic app where I need to check if my file name contains "ABC" then i need to copy file and paste it in ABC folder Azure else need to check if my file name contains "ZYX" then paste it in ZYX folder in Azure.
In switch function its giving me an error.
"The execution of template action 'Switch' failed: The result of the evaluation of 'scope' action expression '#body('Get_file_content')' is not valid. It is of type 'Object' but is expected to be a value of type 'String, Integer'." [Image1]
or if I am trying to use 2 conditions in parallel branch its giving me the below error.
![Image2]
I also tried conditions, if the file name contains "ABC" then copy paste in ABC folder if false then i tried using another conditions inside the false command.
Also, follow up question would be if I have multiple file name with ABC then can I merge and place it in one file and paste that in ABC folder in Azure Blob
Image using switch function:
Image Conditions using parallel branch:
![Image Conditions using parallel branch]
Attaching the latest screenshot with your suggestion.
enter image description here
i just tried using one and its giving me the error.
enter image description here
Reason for the error : You cannot passfile content as a condition check in the switch Connector.
Solution: In order to get the desired output as described above you need to pass the file name as a condition check in switch control. As we receive the File Name from the SharePoint connector as base64 format we need to decode it to string using **base64ToString(FileName)** to compare the folder names present in the containers/blob.
Here is the code view of the logic app based on the above-discussed requirement.
Also, follow up question would be if I have multiple file name with
ABC then can I merge and place it in one file and paste that in ABC
folder in Azure Blob
Using the above flow, merging of files is not possible since each file is saved in different extensions but override of the file takes place in the blob if you are uploading or updating the same file.
For more information about merging of files using Logic app you can refer this BLOG.
UPDATED ANSWER
Before Comparing the string/ Filename you can use 'Compose' before the 'Condition' Connector and convert the string into lower case.
toLower(base64ToString(triggerOutputs()['headers']['x-ms-file-name-encoded']))
Every time I create an element, it is created with the "never_merge_binary" element type.
How can I avoid this in future to have it "compressed_file" rather than "never_merge_binary"?
What param in C:\Program Files\Rational\ClearCase\config\magic\default.magic does this?
First, as I mention in "Check in to ClearCase fails", don't modify directly the default.magic file.
Creating a personal magic file with a name that is alphabetically before the "d" in the default.magic file name (such as cc.magic) will allow ClearCase to parse this file before the default.
Then, define a new type FILE_COPY_MERGE type as described in "Clearcase UCM is trying to merge pdf files", and change your files with that new type (as well as declaring it in cc.magic).
More in "Handling binary files in ClearCase".
I need to validate content of pdf file sent by "File Attachement" component, using Webservice, uploaded by user.
How to do that ?
Action Value Change is not called
ver.orbeon-4.4.0.201311042036-PE
Thanks
Piotr
That probably requires a few steps:
Determine when the upload is complete. With recent versions of Orbeon Forms, the eventxxforms-upload-done can be used.
Send the content of the uploaded file to a service. The file can be a binary file, but there is a way to submit binary content.
Depending on what the service returns, mark the control valid or invalid. You could do this with an attribute on the element holding the uploaded file's URL, e.g.: <my-upload valid="true"/> and then use a constraint like constraint="#valid = 'true'".
I have the following RollingFileappender in my logback configuration file.
<appender name="RollingFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>C:\Files\MyLogFile.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>C:\Files\MyLogFile.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{60} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
It does write to MyLogFile.log but does not append the date as specified in the FileNamePattern.
There is a simular question, but it never answered my confusion.
I should omit the file property.
Why is the file-property then usefull, because it seems to overrule the rolling-file activity.
This confuses me. Did is get something wrong?
The file property, when used along the fileNamePattern one, will define the name of the ACTIVE file, and only archived files will have that pattern as name. When the active file is rolled, a new archive file will be created with that name. From chapter 4 in the manual:
Note that the file property in RollingFileAppender (the parent of TimeBasedRollingPolicy) can be either set or omitted. By setting the file property of the containing FileAppender, you can decouple the location of the active log file and the location of the archived log files. The current logs will be always targeted at the file specified by the file property. It follows that the name of the currently active log file will not change over time. However, if you choose to omit the file property, then the active file will be computed anew for each period based on the value of fileNamePattern.
So it is useful when you want to have a fixed name, for example, if you need to send the active file programmatically and don't want to guess what the file name would be for the current date.
Also notice that file is a property inherited from the regular FileAppender.
I have one temp folder C:\Mydata inside that i have .csv files with name
demo1.csv demo2.csv...etc
Now I want to insert data from all those files into database table
for this I have taken Foreach Loop Container in the property Directory I mention
C:\Mydata
inside Foreach Loop Container taken a Data Flow Task in that Flat File Source is there in the connection manager property in file name what should I mention, so that it will traverse through all folder and all files whose extension is .csv
I did like C:\DEMO\*.csv which is giving me error :
no file found path is wrong
From what i interpreted, your issue was assigning the resulting file from the foreach to the connector.
To do that you need to assign the filename from the Foreach to a variable.
The first step to be taken is to create the variable. To do that you need to activate the "Variables" window:
Then you need to create a new variable of type string and rename it.
For more information on SSIS variables and how to create them, see http://msdn.microsoft.com/en-us/library/ms140216.aspx
Now you need to assign the new variable (in this case i named it "filename") to the foreach loop:
NOTE THAT WHILE THE OPTION "Name Only" IS SELECTED IN THE FIRST WINDOW, IN YOUR CASE YOU PROBABLY WANT "Fully Qualified"!!
The screenshot was taken from a working project i have and i am using only the name (Name Only) as opposed to the full path (Fully Qualified)
After doing that you need to assign that variable to your flat file connector using expressions:
Which version of MSSQL and SSIS are you using? And why are you using C:\Mydata in one place and C:\DEMO in another?
The basic technique of looping over files is described here.
There is lot of information about these steps in the documentation and on the web. If you need more help, please be as specific as possible about what you've tried, what isn't working, what versions you're working with etc.