I am having difficulty moving multiple files .xlsx & .txt to another folder
example: I want to move all filename that contains 0HA_280 to 0HA280 folder
and I have many files to move. Please help I am using Studio X
Use the for each file in folder and in that use the if condition and give the condition as currentfile.name.contains(
(“OHA_280”)
In then block give the move file activity
In else block don’t do anything just leave it as blank. @flashdrive07
Regards
Use for each file in folder activity
Use if currentFile.Name.Tostring.contains(“your string”)
Move file activity
Instead of For Each File with an embedded If, you could just use an expression to get all the files you want. Assign the result to a variable and then For Each through that variable, with the Move File activity inside it, using currentItem.FullName to designate the filename to move.
Create yourFilesVar as IEnumerable(of FileInfo)
Assign yourFilesVar = New System.IO.DirectoryInfo(*folderpath*).GetFiles("*0HA_280*").Where(Function(f) f.Extension.ToUpper = ".XLSX" OR f.Extension.ToUpper = ".TXT")
What should be my next move here in move file?
- In the current scenario give thw to as the destination folder location
- You can use for eqch file in folder and it has a built in filter as well where you can specify the name ypu want to search for as well
Cheers
I kind of solve it already using for each file…
New Question… where can I study this expressions used in studio x?
basic expressions to advance
is there a website where I can study different kinds of expressions ?
Example: create folder using current month in computer?
There is no site as such to learn all
But one thing that would help you now is co pilot in studio which can generate the flow and also can give you expressions by converting natural language
Hope this helps
Cheers
Hello @vrdabberu
yes, I already tried your solution, and it works.
But is there anymore solution than this?
I want to use other solution like using expressions so I can explore more functions in studio X
If you have used DirectoryInfo then the From should be currentItem.FullName.
Then fill in the To with the folder path where you want to move the files. If it needs to be based on the filename then you’ll need something like this…
Else If currentItem.Name.Contains(“0HA_280”)
- Assign DestinationFolder = “\someserver\somefolder\0HA_280”
- If NOT System.IO.Directory.Exists(DestinationFolder)
-
- Create Folder DestinationFolder
Else If currentItem.Name.Contains(“1BC_345”)
- Create Folder DestinationFolder
- Assign DestinationFolder = “\someserver\somefolder\1BC_345”
…etc
Then just put DestinationFolder into the Move File’s To property.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.