Copy several files

lejack02

New Member
Hi all !

Question: At the moment I've got a process going in the main folder, then to each subfolder and copy files 1 by 1 in another folder. Is it possible to select all files in the subfolder and copy them in one shot instead of 1 by 1? Note I cannot directly copy the folder since the receiving environment (Sharepoint) does not accept it.

Thanks for your help !

Have a good week-end in advance !
 

VJR

Well-Known Member
Hi lejack02,
I do not know if there is a direct way to get all files from subfolders without modifying the code of the existing Get Files VBO or by creating a new Code stage.

But there could be other ways to do. See if this works for you.
You can create a batch file and run it from BP and do your job all in one shot.

- Create a new file in notepad saving as .bat and with the following commands
cd /d "c:\Main folder"
for /r %%d in (*.txt) do copy "%%d" "c:\copy here" /y


where 'Main folder' is your source folder and 'copy here' is the destination
If you do not want to copy files with specific extension then put a (*) in place of (*.txt)
/y is to overwrite without prompting

- Run this bat file from Blue Prism by using the 'Start Process' action of 'Utility - Environment'

- The result will be all files from folders and subfolders copied into a single folder in one go.

1521574689586.png
 
Last edited:

cs.andras

Active Member
Hi,
If you want to stick to BP, it might be a useful info for you that directories have no extension. If you check for files like this, you can try (use recovery mode in case it fails) to change to that directory and loop on all files there as well. I hope I made sense :)
You can try to search online for a recursive directory search in general programming languages to help you build the BP logic.
 

lejack02

New Member
Thank you very much both for your support.

I found another way to do it without Get files. I simply loop in the folder and then in the input of copy files [Folder.Path]&"\" and it works !

Yet I have another question : is there a way to run several copy at the same time?
I tried with 2 processes but I have only one machine so this will not work but is there a way to make a process with "one start" and becomes divided in two or three or four and executes the same copy task?

Thank you again !
 

VJR

Well-Known Member
Hi lejack02,

I thought you didn't wanted to loop through every single folder and also copy all files in one shot hence I suggested you the .bat file approach :). I'm glad you were able to achieve what you were looking for using the approach you mentioned.

Regarding your second question, I can't think as of now of having one start and multiple stages running at the same time. I'll let you know if I come across anything. What happened when you tried with 2 processes? Did it not work....maybe you need to play around to modify the run modes (http://rpaforum.net/threads/what-is-the-purpose-of-run-modes-in-blue-prism.824/#post-2141).

But I guess running two process if started at the same time may have Process 1 copy the files from the Folder A and at the same time Process 2 attempts to copy the same files from the same folder in which case it won't find anything and would not serve the purpose of faster copying.

Probably adding files to queues with different tag names could help but this won't be 1 process again.
Process A will add the list of files into a queue with different set of tags to each different set of files.
ie; when you loop through the folders and sub folders keep a counter and for the 1st 10 folders send them to the queue with a tag as "ONE", then the next 10 as TWO" and so on.
Process B will be an exact copy of Process A and will do the same thing as above.
But after finishing placing of the file names in the queue, Process A will only filter items with tags as "ONE" in the Get Next item and copy only those files.
Process B after placing items in queue will only filter items with tags as "TWO" and copy those files.
Both Process A and B are to be scheduled to run at the same time, but I believe you would need to set the run modes to Background to allow both processes to run at the same time. You will have to try changing the modes and see its behaviour. (Or instead of queues you can make use of the 2nd bat file approach wherein Process A will read the 1st 20 lines of the Excel file/Collection and copy only those files while Process B will read the 2nd 20 lines and copy only those.)
If these approaches work for 2 processes then you can try the same using multiple number of processes if there are lot many files.

But see if it is worthwhile adding items to queue or having multiple processes, else it may be faster to complete the copying without the use of queues (or by the 1st bat file approach of copying all files at once).
 

Amir

New Member
Hi VJR,
Thanks a lot for this reply.
I am using same procedure as u mention but still I am facing issue.
Actually for me, the src and destination path are dynamic , i am reading those paths from data item stage.
But the problem is in bat file, both the command lines are coming on same line in .bat file.
I have attached the screen shot as well.
Can you suggest anything ???
 

Attachments

  • Capture.JPG
    85.7 KB · Views: 97

VJR

Well-Known Member
Hi VJR,
Thanks a lot for this reply.
I am using same procedure as u mention but still I am facing issue.
Actually for me, the src and destination path are dynamic , i am reading those paths from data item stage.
But the problem is in bat file, both the command lines are coming on same line in .bat file.
I have attached the screen shot as well.
Can you suggest anything ???
Hi Amir,

Since the post is from several months ago can you post your full and exact issue here. There may even be better and easier solutions by now.
Along with the issue details also share what does the below line mean?
But the problem is in bat file, both the command lines are coming on same line in .bat file.
 

Amir

New Member

Amir

New Member
VJR, Sorry for disturbance ,
I am able to solve this issue, I should do little more handwork before posting here
:):):):)
 

VJR

Well-Known Member
VJR, Sorry for disturbance ,
I am able to solve this issue, I should do little more handwork before posting here
:):):):)
No worries...that happens all the time. By the time a question raises in the mind, the answer has already emerged.
 

rparparpattt

New Member
Hi all !

Question: At the moment I've got a process going in the main folder, then to each subfolder and copy files 1 by 1 in another folder. Is it possible to select all files in the subfolder and copy them in one shot instead of 1 by 1? Note I cannot directly copy the folder since the receiving environment (Sharepoint) does not accept it.

Thanks for your help !

Have a good week-end in advance !

--------------------------------------------------------------------
HOW DO YOU SEND FILES TO SHAREPOINT? I'm trying to send files from my local pc folder to a sharepoint site.
 
Top