Move image from one folder to another

rwahdan
rwahdan Member Posts: 51

Hi,

How to move an image from one folder to another programatically using .net and your API? I found this article but it is not for .net

https://support.cloudinary.com/hc/en-us/articles/202521002-How-to-move-an-asset-from-one-folder-to-another

Tagged:

Best Answer

  • rwahdan
    rwahdan Member Posts: 51
    Answer ✓

    it is giving error if i do this

    fromPublicId = oldPID, toPublicId = newPID
    

    I found a working solution

    RenameParams renameParams = new RenameParams(oldPID, newPID)           

    {               

    FromPublicId = oldPID,               

    ToPublicId = newPID           

    };

Answers

  • Tamara
    Tamara Member, Cloudinary Staff Posts: 123

    Hi @rwahdan,
    To move assets out of a folder:

    • In dynamic folder mode, use the update method with the asset_folder parameter to change the asset's asset folder.
    • In fixed folder mode, use the rename method to change the public ID path (in .NET it's cloudinary.Rename(renameParams);).


    Best,
    Tamara

  • rwahdan
    rwahdan Member Posts: 51

    sorry for asking, how to know if I have dynamic or fixed folders? I am creating folders through API.

  • Vdeub
    Vdeub Member, Cloudinary Staff Posts: 78

    Hi @rwahdan,

    In your Media Library, if you click on an asset and check the Summary tab. If the public_id is editable, it means you have Dynamic folders. (cf screenshot attached).

    Hope that helps.

    Best,

    Loic

  • rwahdan
    rwahdan Member Posts: 51
    edited April 8

    here is a screenshot, does that mean it is fixed?

    but if i open the image i can edit it

  • Vdeub
    Vdeub Member, Cloudinary Staff Posts: 78

    Hi @rwahdan,

    Yes, it means you don't have Dynamic folders.

    Regards,

    Loic

  • rwahdan
    rwahdan Member Posts: 51

    Here is what I tried:

    RenameParams renameParams = new RenameParams()

    {               

    FromPublicId = oldPID,

    ToPublicId = newPID           

    };

    getting error:

    error CS7036: There is no argumen
    t given that corresponds to the required parameter 'fromPublicId' of RenameParams.RenameParams(string, string)

  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 170 admin

    Hi,

    Please use the first character as lower case like the following:

    RenameParams renameParams = new RenameParams(){ fromPublicId = oldPID, toPublicId = newPID};
    

    Let me know if there's still an issue.

    Regards,
    Anthony

    Developer Support Engineer
    Cloudinary


    Helpful Links For You
    💬 Share questions, connect with other users in our Cloudinary Community forums and Discord server!
    🧑‍🎓 Join our Cloudinary Academy for free courses, workshops and other educational resources.
    📄 Read our documentation for in-depth details on Cloudinary product features and capabilities
    📰 Check out the Cloudinary blog for the latest company news and insights