I have multiple types of files in a folder, I want to fetch only pdf and moved in a seprate folder. I am using the below approach, but I don’t see the option where I have to pass a this pdf loop variable. or any other approach better than this, plz guide.
@Palaniyappan plz guide
You can get by this Buddy
Outfilepath = Directory.Getfiles(“yourfoldername”,“*.pdf”)
Then use this in for each loop @balkishan
And simply use move activity and pass the variable item as source path and
Destination as your path you want
Cheers @balkishan
Yes I did this, but in the loop part what I have to do, as I used move activity in this there is only two option from and destination folder path. I don’t see the option where I have to pass pdf varable.
There is a property called FROM
There mention as item, the variable that we obtain from for each loop
And in DESTINATION… mention tye path where you want to move
Cheers @balkishan
@balkishan, in destination path you can use your pdf variable. It will rename the file with your variable name.
Did that work Buddy
Cheers @balkishan
Mention this in Move File activity.
From - Path: pdf
To - Destination: “Destination FolderPath”
@balkishan Refer This
I’ve to move the word also so can I can give both the extension at same time?
Is the folder contains only PDF and Word files ? And also you want to move all files in that folder ?
If yes then
String files [ ] = Directoty.Getfiles(“FolderPath”)
Aaah…we need another loop with same steps…but in directory.getfiles(“yourfolderpath”,"*.docx)
Only if the folder has those type of files then you can simply mention like
Directory.getfiles(“yourfolderpath”)
Cheers @balkishan
It’s containing multiple files images also, png jpeg, pdf, doc, docx like this
so I have to move the pdf and the docx files only.
Bro can’t we use in the same loop? If we give this extension one by one,
Like this 
we can use two loop but it better if we use one loop only.
Then we need a separate loop buddy @balkishan
As suggested earlier @balkishan
Buddy, only two arguments can be passed for getfiles method…
Foldepath and filepath
Cheers @balkishan
Simply use if condition inside the loop. If name contain your extension (like .pdf), then use move file activity in the Then block. It will move only files you want.
TanQ,
Mic
Yes no need of two loops and we can do it with one loop only.
-
String files = Directoty.Getfiles(“FolderPath”)
-
use For Each loop to iterate that array of files.
ForEach item in files if item.ToString.Contains("pdf") or item.ToString.Contains("docx") or item.ToString.Contains("doc") Then: use **Move File** activity and mention below. From - Path: item To - Destination: “Destination FolderPath”
@lakshman it’s not going into the move activity, It contains the all files in a folder and it just touch the if area but not going into the Move activity?

@lakshman If you see this now it’s on the if activity but not going into the then part

Fine we can try with a if activity…
The condition should be like this buddy
Item.ToString.contains(“.pdf”) or Item.ToString.contains(".docx)
Don’t put star before dot… Cheers @balkishan
It should be like this: Contains(“pdf”) or Contains(“docx”) or Contains(“doc”)

