How can I rename these file to to its corresponding values using key, key may not be exact to the file name part but both the key and parts of the file name has similar name which is A1.
what location do i put for value to save
and could you explain each part of your process. thanks
-
Assign key = “” (initialize an empty string)
-
For Each file in Directory.GetFiles(directoryPath)
- Assign key = “” (reset the key for each file)
- For Each potentialKey in keys (where keys is a list or array of possible keys)
- If file.Contains(potentialKey) (check for similarity)
- Assign key = potentialKey (set the key)
- If file.Contains(potentialKey) (check for similarity)
- If key <> “” (a valid key was found)
- Assign newFileName = Path.GetFileNameWithoutExtension(file) + “_” + key + Path.GetExtension(file) (construct the new file name)
- File.Move(file, Path.Combine(directoryPath, newFileName)) (rename the file)
i have this error
yes i put it correctly but still have this
If the key is always <RequiredValue Name>
Then please follow
- Read the data into datatable dt
- Now use for each file in folder with
"*.docx"
as filter - Use lookup datatable activity and pass the column index as 0 and value to search as
"<" + currentFile.Name.Replace(currentFile.Extension).Split("-"c)(1).Trim + " Name>"
and save the output variable and give output column index as 1 and say output variable is str - Inside loop use rename file activity…pass file as
currentFile.FullName
in rename field passcurrentFile.Name.Replace(currentFile.Name.Replace(currentFile.Extension).Split("-"c)(1).Trim,str)
Cheers
Could you sent me in UiPath as im still new to this hence im asking for help. thank you
Cheers
but what if my keys are different, these are the files
MASTER FILE.xlsx (19.5 KB)
1.File- A2.docx (15.4 KB)
1.File- A1.docx (15.3 KB)
I think is because the variable Doc_name contains RP, the error is something there but im not sure, do let me know
@Helpmepls its because of there is no key in the dictionary with that name please the key name in the dictionary
how do i do that is it possible to sent a updated one using key and value in the excel i sent to you
Cheers
is there something wrong with this, do let me know as im confused, i thought the keys are in the excel file i sent why need manually key.
cheers
any updates? thank you