I need an assistance in a scenario where i want to rename same files after copying in same folder.
Ex: lmn.cfg_201806, pqr.cfg_201806 (Filenames)
I copied these files from source path to target path.Now i want to rename these files from lmn.cfg_201806 to lmn.cfg
Using this flow for above mentioned activities.
After Copying files Output of ls command is ( where lmn.cfg_180918 and pqr.cfg_180918 are scrap files , we can ignore)
After Rename : Output of mv command
It Renames pqr.cfg_201806 to lmn.cfg (while it should rename mn.cfg_201806 to lmn.cfg ) and for next file it says file does not exist.
I'm not sure that I understood your requirement correctly, but it maybe easy to use bat/shell script instead of RA flow to rename multiple files.You can run the script using "Run Command Line" action type.
Already I am using mv command in Run Command Line action to rename multiple files..
The devil is usually in the details. I don't know for sure exactly how its going about renaming the files, but I see there are some loops taking place. If it is looping based on an array of the filenames then I can imagine a scenario where the rename files piece might mix up the files being renamed. If this scenario is what's happening then I'd imagine you have two options:
1. rename the files without a loop and hard code the source filename; or
2. use some parsing actions that confirms the filename being picked up in the loop so that you know which file you're renaming and rename it accordingly.
I am not clear what you are suggesting...
In loop i am trying to rename the files from lmn.cfg_201806 to lmn.cfg and pqr.cfg_201806 to pqr.cfg..
File name before mv command
After mv command
Can't hard code the source filename as file name can change in future
Tried with Strings - Check for Sub string In Source
I don't know if this is what's happening - again, devil is in the details (which in this case is if/where you are using parameters, arrays, etc.. in each of the actions, loops, etc..).
But, in the example above, please show us what your workflow looked like to produce #2 and #1. And also please show us the properties of the action(s) for that "Check for Sub string in Source" action so that we can be clear.
If you need additional logic to rename these files, you can implement in a shell script and call the script using "Run Command Line" action. I didn't mean to call mv command from the action directly.
Here is another idea. Use rename command instead of mv.
rename .cfg_201806 .cfg *
If '_201806' may be changed in future, it can be set to a parameter. After that, call the command with the parameter.
Complete file name can change in future, not sure about ' _201806'., it can be any file type .cfg, .txt etc.
Anyway i find out the solution..let me share .(I forgot to add the splitted array loop )