Skip to content

Instantly share code, notes, and snippets.

@rogerblanton
Created January 16, 2024 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerblanton/5ddd91e2e491d4a093b4075cecdd568a to your computer and use it in GitHub Desktop.
Save rogerblanton/5ddd91e2e491d4a093b4075cecdd568a to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
path="/etc/sling/slingpiper.config.xml">
<!-- Define the Sling Pipe configuration -->
<sling:config
jcr:primaryType="sling:OsgiConfig"
enabled="{Boolean}true">
<!-- Define the Sling Pipe statements -->
<statements jcr:primaryType="nt:unstructured">
<!-- Query to find assets with JobID property -->
<query
jcr:primaryType="nt:unstructured"
path="/content/dam"
type="nt:file"
statement="SELECT * FROM [nt:base] WHERE ISDESCENDANTNODE('/content/dam') AND [jobID] IS NOT NULL">
<!-- Capture folderName and jobID variables from the query result -->
<variable
jcr:primaryType="nt:unstructured"
name="folderName"
expression="${jobID}"/>
<variable
jcr:primaryType="nt:unstructured"
name="jobID"
expression="${jobID}"/>
</query>
<!-- Loop over the result set and execute the following statements -->
<loop
jcr:primaryType="nt:unstructured"
path="/content/dam/%folderName%"
type="nt:file">
<!-- Create a folder with JobID as folder name -->
<createFolder
jcr:primaryType="nt:unstructured"
path="/content/dam/%folderName%"
type="sling:Folder"/>
<!-- Move assets with JobID metadata to the folder -->
<move
jcr:primaryType="nt:unstructured"
source="/content/dam"
type="nt:file"
condition="%jobID%='%folderName%'"
destination="/content/dam/%folderName%"/>
</loop>
</statements>
</sling:config>
</jcr:root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment