code: public void adjustLinks(String sourceFolder, String targetFolder) throws CmsException {
  
          String rootSourceFolder = addSiteRoot(sourceFolder);
          String rootTargetFolder = addSiteRoot(targetFolder);
          String siteRoot = getRequestContext().getSiteRoot();
          getRequestContext().setSiteRoot("");
          try {
              CmsLinkRewriter linkRewriter = new CmsLinkRewriter(this, rootSourceFolder, rootTargetFolder);
              linkRewriter.rewriteLinks();
          } finally {
              getRequestContext().setSiteRoot(siteRoot);
          }
      }
docs: Adjusts all links in the target folder that point to the source folder
  so that they are kept "relative" in the target folder where possible.
  
  If a link is found from the target folder to the source folder,
  then the target folder is checked if a target of the same name
  is found also "relative" inside the target Folder, and if so,
  the link is changed to that "relative" target. This is mainly used to keep
  relative links inside a copied folder structure intact.
  
  Example: Image we have folder /folderA/ that contains files
  /folderA/x1 and /folderA/y1. x1 has a link to y1 and y1 to x1.
  Now someone copies /folderA/ to /folderB/. So we end up with
  /folderB/x2 and /folderB/y2. Because of the link mechanism in OpenCms,
  x2 will have a link to y1 and y2 to x1. By using this method,
  the links from x2 to y1 will be replaced by a link x2 to y2,
  and y2 to x1 with y2 to x2.
  
  Link replacement works for links in XML files as well as relation only
  type links.
  
  @param sourceFolder the source folder
  @param targetFolder the target folder
  
  @throws CmsException if something goes wrong