How to select and move images, identified by a column 'image1.jpg' in xls, from one folder to another

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.

Thank you
Doug

@Wyohost

Welcome to the UIpath Community.

  1. First use Read Range activity to read image file names and will give you output as dataTable and say ‘DT’.

  2. 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.

Thank you…it might take a bit for me to get my head around it all but I’ll give it a go.

Thanks again
Doug

1 Like

Hi again…
I don’t understand the For Each Row…Something doesn’t look quite right.

seeitreate that dataTable.

I’m guessing means ‘see it create’ that table.

This I don’t understand.

  • string file = Directory.GetFiles(“FolderPath”,row(“FilesColumnName”).Tostring)

Thanks

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

According to your Need
Check this workflow
Folders for Images.xaml (6.4 KB)

4 Likes

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)

Can you help me work around this?
Thanks

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

@TUSHAR_DIWASE

Thank you … That makes sense.

I’ve created an if condition and moved the action into the ‘else’ box.
I’m getting the error

    Compiler error(s) encountered processing expression "string.IsNullOrEmpty(row(“imagefile”))".
    Option Strict On disallows implicit conversions from 'Object' to 'String'.

string.IsNullOrEmpty(row(“imagefile”).ToString)
Try this

@Wyohost

It should be like this:

string.IsNullOrEmpty(row(“imagefile”).ToString)

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)

Thank you
Doug

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?

Again, thank you for your help.

@Wyohost

Have you completed all levels training in UiPath academy or not ?

And also you can enroll in udemy site and learn but for this you need to pay money. This is also good training for beginners.

hello @Wyohost

i would recommend you to go this website https://academy.uipath.com sign up and learn

Back to your query

You can simply use try catch activity and specify the exception you are getting to easily solve the above issue

Check this workflow for better understanding
Folders for Images.xaml (8.5 KB)

1 Like