Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges


How to move assets from one path to another path in damadmin with updated references where the image used in pages


I want to move images from one path to path with updated references , can someone explain the best possible solution for that.

i want to make sure that it should not effect the pages where the old path images are used as because i want to do this PROD server.

1 Accepted Solution


Correct answer by
Community Advisor

When you goto /damadmin and select an asset to move, it shows all the references of that asset in the dialog and ask if it has to be adjusted for the new link and it would take care by itself

So, you can use the 'move' option in damadmin

View solution in original post

3 Replies




Please have a look at these reference links, it is not completely covering what you are asking but covers most of it:


//Moving DAM Assets using the Adobe Experience Manager Granite AssetManager API



//Move/Copy Multiple DAM assets in different folders.






//How to move assets in different directory using java service


I hope this will help you.

Thanks and REgards

Kautuk Sahni


Correct answer by
Community Advisor

When you goto /damadmin and select an asset to move, it shows all the references of that asset in the dialog and ask if it has to be adjusted for the new link and it would take care by itself

So, you can use the 'move' option in damadmin


Level 1


If the assets and referenced pages are more, then you can create one groovy script or servlet which will read the asset files from specific folder and move it to destination folder. Continuing to same script create one query which will read the nodes from provided path for reading the property value and if any property matches with old asset path then set the same property with new asset path where the asset is moved. Please find below Servlet example for one the we-retail asset movement and reference update.


import java.util.HashMap;
import java.util.Map;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Session;
import javax.jcr.Value;
import javax.servlet.Servlet;
import org.osgi. framework.Constants;
import org.osgi. service.component.annotations. Component ;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.adobe.granite.asset.api.AssetManager;
import search.QueryBuilder;

@component(service =Servlet.class,
property = {
Constants.SERVICE_DESCRIPTION + "= Asset Migration Servlet",
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths=" + "/bin/assetmigration/update"
public class AssetMigrationServlet extends SlingSafeMethodsServlet{

private static final long serialVersionUID = 7524136240611031420L;
private static final Logger LOGGER = LoggerFactory.getLogger(AssetMigrationServlet.class);

private QueryBuilder builder;

private static final String CONTENT_PATH = "/content/dam/we-retail/en/products/apparel/scarfs/";

protected void doGet (SlingHttpServletRequest request, SlingHttpServletResponse response) {"Asset Migration Servlet Called successfully!! ");

try {
ResourceResolver resourceResolver = request.getResourceResolver();
AssetManager assetManager = resourceResolver.adaptTo(AssetManager.class);

Session session = resourceResolver.adaptTo(Session.class);
if(session.nodeExists(CONTENT_PATH)) {

Node parentNode = session.getNode(CONTENT_PATH);

if(parentNode.hasNodes()) {
NodeIterator childNode = parentNode.getNodes();

while(childNode.hasNext()) {
Node assetNode = childNode.nextNode();
String assetName = assetNode.getName();

String assetPath = CONTENT_PATH + assetName;
String movePath = "/content/dam/we-retail/en/" + assetName;

if(assetName.equalsIgnoreCase("jcr:content")) {"JCR:CONTENT Node found, hence skipped movement...");
}else {
assetManager.moveAsset(assetPath, movePath);
Map<String, String> predicate = new HashMap<>();

predicate.put("path", "/content/we-retail");
predicate.put("fulltext", assetPath);

Query query = builder.createQuery(PredicateGroup.create(predicate), session);


SearchResult searchResult = query.getResult();

for(Hit hit : searchResult.getHits()) {

String path = hit.getPath();

Node node = session.getNode(path);

PropertyIterator pitors = node.getProperties();
while(pitors.hasNext()) {

Property ps = pitors.nextProperty();
if(ps.isMultiple()) {
Value vr[] = ps.getValues();
for (int i = 0; i < vr.length; i++) {
response.getWriter().println("*****************************Property Value:::::::::::::" + vr[i]);
}else {
String value = ps.getValue().toString();
if(ps.getValue().toString().equalsIgnoreCase(assetPath)) {
String propertyValue = ps.getValue().toString();
response.getWriter().println("***********************OLD Property Value***************:" + propertyValue);
String temp = propertyValue;
String newValue = temp.replace(assetPath, movePath);
propertyValue = newValue;
node.setProperty(ps.getName().toString(), newValue);
response.getWriter().println("*************************Updated Property :" + node.getProperty(ps.getName() + " With Value:::::::::::::::::" + movePath));
response.getWriter().println("**************************************Updated Value for the node****************************:" + path);
response.getWriter().println("***********************************Asset With Name: " + assetPath + " is Moved to: " + movePath);

}catch(Exception e) {