Hey,
Either you can iterate across each loop based on the parameter that is passed as stated by Amira,
or you can use the below expression format :
@or(contains(item().name, 'LosAngeles'), contains(item().name, 'NewYork'))
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This is very related to my previous posts, but I am posting it here with more focused scenario (and I did not get the solution yet).
I am trying to write an expression to do this:
Go thru each csv files, and move csv files to either folder A or folder B based on the name of csv files (whether certain words are contains or not).
The results should be boolean (true or false) because I am using IF Condition:
So, I am trying to go thru each csv files and create a logic like "if csv file has "LosAngeles" on the file name, this file will to go Folder A".
And "if csv file has word "NewYork" on the file name, this file will to go Folder B. etc"...
@contains(
activity('Get Metadata2').output.itemName,
["LosAngeles","NewYork","SanFrancisco"]
)
Initially, I was trying to use array parameter Cities
(to hold values) ,but I do not understand how to use the array parameter.
"Cities": [
"LosAngeles",
"NewYork",
"SanFrancisco",
// ... more cities
]
If using array parameter is way to go, please let me know.
Thanks.
Hey,
Either you can iterate across each loop based on the parameter that is passed as stated by Amira,
or you can use the below expression format :
@or(contains(item().name, 'LosAngeles'), contains(item().name, 'NewYork'))
I already left a comment on your last post and I will try to answer this one :
You can use the "Get Metadata" activity to get a list of files (CSV) in a specific directory.
Use a "ForEach" activity to iterate through each file.
Within the ForEach activity, use an "IF Condition" activity to apply your logic for moving files. The expression could be similar to:
@contains(item().name, 'LosAngeles')
In the "True" activity path, you can have a "Copy Data" activity to move the file to Folder A. Similarly, in another "IF Condition" activity, you can check for other city names.
Use "Copy Data" activities to copy the files from source to destination based on the conditions.
Here's a rough pseudo-JSON structure:
"ForEach": {
"Items": "@activity('Get Metadata2').output.childItems",
"BatchCount": 10,
"Activities": [
{
"If Condition": {
"Expression": "@contains(item().name, 'LosAngeles')",
"True Activities": [
{
"Copy Data": {
"Source": ...,
"Destination": "Folder A"
}
}
],
"False Activities": [
{
"If Condition": {
"Expression": "@contains(item().name, 'NewYork')",
"True Activities": [
{
"Copy Data": {
"Source": ...,
"Destination": "Folder B"
}
}
],
...
}
}
]
}
}
]
}
If you need more advanced file manipulation, you might consider using Azure Functions with a Blob Trigger, or an Azure Logic App, which would allow you to write more complex code in a language like C# or JavaScript. If you need to authenticate against Azure AD, you would use the appropriate SDK or REST API calls for that service, such as the Microsoft Graph API.