How Can I Rename Dynamic Content File?

I’m using invoke method to rename file , It works If I use default content file in old path for new name in new path but I can’t rename dynamic Content File . Invoke Method File display that : “File Not Found” . How can I fix it ?

Ex : Old File : “portal.auone.jp_13118.png” , 13118 is dynamic number . Some time It will be changed another number when my url called

Hi @Anh_Nguyen

you can use the below approach

Assign arr_files = Directory.GetFiles("Your Folder Path","portal.auone.jp_*.png").OrderBy(Function(d) New FileInfo(d).CreationTime).ToArray  //This will provide all the files in that folder sorted based on creation time.
Str_filename = arr_files(0)  //This will get the first file which is most recent one

you can use this variable to get the file name and rename it as per your existing logic.

HI @Anh_Nguyen

Try like this

  • Use For each file in folder and pass your path.
  • And if you use will get you the name.extension whatever the name can be
    if you want path pass currentfile.tostring



Hi , bro . It works . Thanks for investing time .

1 Like

Hi , bro . I have another problem

Ex : This is my dynamic url :*

It’s different between “tr” and “not tr” . Some time url was generated include tr , some time it was not . So, How can I rename a file by contains string in url ( not full string url ) ?

Hi @Anh_Nguyen Sorry could you provide some more details. What exactly you are trying to accomplish.

Firstly , Thanks for taking time . I have file with dynamic name which generated from my url .
But My dynamic file some time include “tr” at last , some time it’s not
example : abc_edf/q=‘1234’/tr=‘123’.png

I can rename file dynamic with ‘abc_edf/q=*’ as you said . But when file add more ‘/tr=…’ . I can’t rename . so , How can I do it ?

Hi @Anh_Nguyen

As far as I understood the last tr should not be a problem right because we are searching for the starting text which is more common and with the help of that we are going to get the full file name and you would be replacing that entire name with the new name.

Maybe if you can share if your original scenarios like

  1. old name 2. New Name you would like to rename with a few examples that would provide some insights and maybe I can help based on that.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.