Release Automation

Expand all | Collapse all

Loop

  • 1.  Loop

    Posted 09-19-2018 01:05 PM

    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.

     



  • 2.  Re: Loop

    Posted 09-20-2018 03:57 AM

    Hi,

     

    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.

     

    Regards

    Yas



  • 3.  Re: Loop

    Posted 09-20-2018 05:45 AM

    HI Yasuki,

     

    Already I am using mv command in Run Command Line action to rename multiple files..



  • 4.  Re: Loop

    Posted 09-20-2018 09:22 AM

    Hi,

     

    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. 

     

    Kind regards,

    Gregg



  • 5.  Re: Loop

    Posted 09-20-2018 10:43 AM

    Hi Gregg,

    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 

    Please suggest.



  • 6.  Re: Loop

    Posted 09-20-2018 10:50 AM

    Hi Gregg,

    1. rename the files without a loop and hard code the source filename; or

    Can't  hard code the source filename as file  name can change in future

     

    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. 

    Tried with Strings - Check for Sub string In Source



  • 7.  Re: Loop

    Posted 09-20-2018 10:58 AM

    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. 

     

    Regards,

    Gregg



  • 8.  Re: Loop

    Posted 09-21-2018 12:29 AM

    Hi,

     

    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.

     

    Thanks

    Yas



  • 9.  Re: Loop

    Posted 09-21-2018 01:51 PM

    Hi Yasuyuki,

     

    Thanks.

    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 )