Hi all,
I am trying to rename a specific file among its other files. So, in an array I have 9 files, and I need to rename every file with the keyword WB. So here is an example:
Before rename: Example_WB_MME
After rename: TP#Example_WB
Cheers
Hi all,
I am trying to rename a specific file among its other files. So, in an array I have 9 files, and I need to rename every file with the keyword WB. So here is an example:
Before rename: Example_WB_MME
After rename: TP#Example_WB
Cheers
Loop on the files in a folder
Directory.GetFiles(“Your folder path”)
For renaming: Use rename file activity
Hi @SRoyi
You can get all the file names in an array using the following expression:
filesNameArray = Directory.GetFiles("Folder Path in which files are present")
Then use a For Each currenFileName in the filesNameArray
variable & use the Rename File activity inside the loop to rename the file.
You can rename it like this:
Assign 1: newFileName = “TP#”+currentFileName.ToString
Assign 2: newFileName.Replace(“_MME”,“”)
Hope this helps,
Best Regards.
Try this xaml file where I used the For Each File in Folder activity and then used an Assign activity to change the name. After that, the Rename File activity was used to execute the changes:
RenameFiles.xaml (8.3 KB)
Make sure to change your target folder when you try it:
If you’re not processing the entire folder, you can loop For Each in the array that you currently have.
This is the code for the Assign activity:
strNewFileName = Path.Combine(Path.GetDirectoryName(CurrentFile.ToString), "TP#" + Path.GetFileNameWithoutExtension(CurrentFile.ToString).Replace("_MME", "") + "." + Path.GetExtension(CurrentFile.ToString))
Hope this works for you! thanks
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.