I have a single folder with 1000’s of images.
I have several product category xls files with a column that has the image name.
I’d like to read the image name in the xls file’s, search the main image folder, and move the images into it’s own corresponding folder.
I found UiPath just today. It’s something that isn’t completely foreign as in I understand the concept. What I don’t understand is all the commands.
I’ve watched several of the tutorial videos including how to move files and how to create new data tables, but what I haven’t figured out is how to use one to do another.
Any tutorials out there or guidance is surely appreciated.
First use Read Range activity to read image file names and will give you output as dataTable and say ‘DT’.
Then use For Each Row activity to itreate that dataTable.
- string file = Directory.GetFiles(“FolderPath”,row(“FilesColumnName”).Tostring)
Then use Move file activity to move file from source to destination.
Hello @Wyohost Iteration mean repetition of your process in short what your For Each will do is it’ll go through every value one by one from your excel file and do the process until it finishes it
AND
this code Directory.GetFiles(“FolderPath”,row(“FilesColumnName”).Tostring)
Ill explain you Directory.GetFiles(“FolderPath” will get all files from that path you’ll provide
& row(“FilesColumnName”).Tostring) this code means we are taking data from excel sheet from column name “FilesColumnName”
We can also use row(0).tostring here we are taking the identifying it using its index and not its column name
Thank you @vickydas, I think I have it worked out for the most part…
I’m having an issue with when there is no image for a file name in the xls. When it reaches a file name that doesn’t exist it throws a not found exception error.
19.5.0+Branch.master.Sha.a03bc4726ca82b7bb3addb0d04106dc150b31fba
Source: Move File
Message: Could not find file 'D:\Wyohost Business\Clients\Solidsnstripes\1-Cuestix files\EBM01.jpg'.
Exception Type: System.IO.FileNotFoundException
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.IO.FileNotFoundException: Could not find file 'D:\Wyohost Business\Clients\Solidsnstripes\1-Cuestix files\EBM01.jpg'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
at UiPath.Core.Activities.MoveFile.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
directory.GetFiles("D:\Wyohost Business\Clients\Solidsnstripes\Working_POS_CSV_Files\Action",row("imagefile").Tostring)
In for loop you can check whether image field is empty or not
If condition → string.IsNullOrEmpty(row(“image field name”))
True → do your normal activity
False → do nothing
Thank you to each of you trying to help…I really really appreciate it and it really sucks I don’t understand this more…I eat new software for lunch and this is just over the top, so many moving parts and possibilities. I can see why a specialist in this area is so valuable…therefor again, Thank You.
I started with the file that @vickydas provided, thank you. If I understand the process correctly, this error I’m getting is suggesting that I don’t have one of the ‘if’ conditions set…which I don’t. @TUSHAR_DIWASE I don’t know how to create a ‘do nothing’ command.
This is the error…
19.5.0+Branch.master.Sha.a03bc4726ca82b7bb3addb0d04106dc150b31fba
Source: Read Range
Message: Object reference not set to an instance of an object.
Exception Type: System.NullReferenceException
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.NullReferenceException: Object reference not set to an instance of an object.
at UiPath.Excel.Activities.WorkbookActivity`1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
I want to throw this out there and ask a question…
After someone gives me a bit of advice on what to do next…I really do search out more understanding, not just get an error and pop back here with another question…so let me also ask this…does anyone have a ‘beginner’s training’ source for UiPath? I’ve watched several of the tutorial videos in the training but not all of them and only a couple of them twice.
Is this going to be my best resource or are there another/others to learn from that breaks things down a bit more?