<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Automatic Folder creation in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/automatic-folder-creation/m-p/137968#M37010</link>
    <description>&lt;P&gt;Thanks for the answer, i have this scrit that runs wherever any folder are created in this workspace, the script runs automatically trough folder rules and works fine, except when the destination folder already exists, I give a look at source code of the page itself and notice that even that apears to have 2 folders with the same name (impossible with alfresco rules), turns out that the source code for the folder tiltle has a '&amp;amp;nbsp' caracter in spaces, so when my script compares the two folders name "ATESTADOS MÉDICOS" with&amp;nbsp;"ATESTADOS&amp;amp;nbspMÉDICOS", visually they are the same because html puts a space at '&amp;amp;nbsp' location, when my script compares they are not the same.&lt;/P&gt;&lt;P&gt;Now I Have two change all the&amp;nbsp; '&amp;amp;nbsp' im my folders name.&lt;/P&gt;&lt;P&gt;Someone has an idea how to acomplish that?.&lt;/P&gt;</description>
    <pubDate>Fri, 14 May 2021 16:47:15 GMT</pubDate>
    <dc:creator>CRISTIAN_MULLER</dc:creator>
    <dc:date>2021-05-14T16:47:15Z</dc:date>
    <item>
      <title>Automatic Folder creation</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/automatic-folder-creation/m-p/137966#M37008</link>
      <description>&lt;P&gt;Hello guys, I have a folder rule that runs when a folder are created at a specific place, the problem is, i have to search if a folder exists , when exists i have to create some subfolders, the problem is, whem the first folder dont exists, a folder are created and subfolders too, but when the folders exists, another folder are created with the same name the original and the subfolders are created inside this new folder.&lt;/P&gt;&lt;P&gt;My question is, how can I search for a folder and create contetn inside of it without creating a new folder.&lt;/P&gt;&lt;P&gt;thats my script&lt;/P&gt;&lt;P&gt;var ATESTADOS = document.childByNamePath("ATESTADOS&amp;nbsp;MÉDICOS");&lt;BR /&gt;if ( ATESTADOS == null &amp;amp;&amp;amp; space.hasPermission("CreateChildren"))&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;// create ATESTADOS&amp;nbsp;MÉDICOS&lt;BR /&gt;ATESTADOS = document.createFolder("ATESTADOS&amp;nbsp;MÉDICOS");&lt;BR /&gt;var parentNode = ATESTADOS.parent;&lt;BR /&gt;parentNode.setInheritsPermissions(false);&lt;BR /&gt;parentNode.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;&lt;BR /&gt;ATESTADOS.setInheritsPermissions(false);&lt;BR /&gt;ATESTADOS.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;var caminho = document.name;&lt;BR /&gt;&lt;BR /&gt;var First_Name= caminho.match(/^(\S+)\s(.*)/).slice(1,2)&lt;BR /&gt;var Last_Name= caminho.match(/^(\S+)\s(.*)/).slice(2,3)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;var query = search.query({query:"@cm\\:firstName:\"'"+First_Name+" '\" AND &lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/78554"&gt;@CM&lt;/A&gt;\\:lastName:\"'"+ Last_Name+"'\""});&lt;/P&gt;&lt;P&gt;var nome= query[0].properties.userName;&lt;BR /&gt;parentNode.setPermission("Consumer", nome);&lt;BR /&gt;ATESTADOS.setPermission("Consumer", nome);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;var BENEFÍCIOS = document.childByNamePath("BENEFÍCIOS");&lt;/P&gt;&lt;P&gt;if ( BENEFÍCIOS == null &amp;amp;&amp;amp; space.hasPermission("CreateChildren"))&lt;BR /&gt;{&lt;BR /&gt;// create BENEFÍCIOS with some subfolders&lt;BR /&gt;BENEFÍCIOS = document.createFolder("BENEFÍCIOS");&lt;BR /&gt;BENEFÍCIOS.setInheritsPermissions(false);&lt;BR /&gt;BENEFÍCIOS.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;BENEFÍCIOS.setPermission("Consumer", nome);&lt;BR /&gt;&lt;BR /&gt;var TICKET = document.childByNamePath("BENEFÍCIOS/TICKET");&lt;BR /&gt;TICKET = BENEFÍCIOS.createFolder("TICKET");&lt;BR /&gt;var VALE_TRANSPORTE = document.childByNamePath("BENEFÍCIOS/VALE TRANSPORTE");&lt;BR /&gt;VALE_TRANSPORTE = BENEFÍCIOS.createFolder("VALE TRANSPORTE");&lt;BR /&gt;var PLANO = document.childByNamePath("BENEFÍCIOS/PLANO DE SAÚDE");&lt;BR /&gt;PLANO = BENEFÍCIOS.createFolder("PLANO DE SAÚDE");&lt;BR /&gt;var PLANO_ODONTO = document.childByNamePath("BENEFÍCIOS/PLANO ODONTOLÓGICO");&lt;BR /&gt;PLANO_ODONTO = BENEFÍCIOS.createFolder("PLANO ODONTOLÓGICO");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;var CERTIFICADOS = document.childByNamePath("CERTIFICADOS");&lt;BR /&gt;if ( CERTIFICADOS == null &amp;amp;&amp;amp; space.hasPermission("CreateChildren"))&lt;BR /&gt;{&lt;BR /&gt;// create Documentazione with some subfolders&lt;BR /&gt;CERTIFICADOS = document.createFolder("CERTIFICADOS");&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;CERTIFICADOS.setInheritsPermissions(false);&lt;BR /&gt;CERTIFICADOS.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;CERTIFICADOS.setPermission("Consumer", nome);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var CONTRACHEQUE = document.childByNamePath("CONTRACHEQUE");&lt;BR /&gt;if ( CONTRACHEQUE== null &amp;amp;&amp;amp; space.hasPermission("CreateChildren"))&lt;BR /&gt;{&lt;BR /&gt;// create Documentazione with some subfolders&lt;BR /&gt;CONTRACHEQUE = document.createFolder("CONTRACHEQUE");&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt;CONTRACHEQUE.setInheritsPermissions(false);&lt;BR /&gt;CONTRACHEQUE.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;CONTRACHEQUE.setPermission("Consumer", nome);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var DOCUMENTOS_INTERNOS = document.childByNamePath("DOCUMENTOS&amp;nbsp;INTERNOS");&lt;BR /&gt;if ( DOCUMENTOS_INTERNOS == null &amp;amp;&amp;amp; space.hasPermission("CreateChildren"))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;{&lt;BR /&gt;// create DOCUMENTOS&amp;nbsp;INTERNOS with some subfolders&lt;BR /&gt;DOCUMENTOS_INTERNOS = document.createFolder("DOCUMENTOS&amp;nbsp;INTERNOS");&lt;BR /&gt;&lt;BR /&gt;var PENALIDADES = document.childByNamePath("DOCUMENTOS&amp;nbsp;INTERNOS/PENALIDADES");&lt;BR /&gt;PENALIDADES = DOCUMENTOS_INTERNOS.createFolder("PENALIDADES");&lt;BR /&gt;var DIVERSOS = document.childByNamePath("DOCUMENTOS&amp;nbsp;INTERNOS/DIVERSOS");&lt;BR /&gt;DIVERSOS = DOCUMENTOS_INTERNOS.createFolder("DIVERSOS");&lt;BR /&gt;var TESTES_E_AVALIACOES_DE_ADMISSAO = document.childByNamePath("DOCUMENTOS&amp;nbsp;INTERNOS/TESTES E AVALIACÕES DE ADMISSÃO");&lt;BR /&gt;TESTES_E_AVALIACOES_DE_ADMISSAO = DOCUMENTOS_INTERNOS.createFolder("TESTES E AVALIACÕES DE ADMISSÃO");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;var DOCUMENTOS_INTERNOS = document.childByNamePath("DOCUMENTOS&amp;nbsp;INTERNOS");&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//var PENALIDADES = document.childByNamePath("DOCUMENTOS&amp;nbsp;INTERNOS/PENALIDADES");&lt;BR /&gt;PENALIDADES = DOCUMENTOS_INTERNOS.createFolder("PENALIDADES");&lt;BR /&gt;//var DIVERSOS = document.childByNamePath("DOCUMENTOS&amp;nbsp;INTERNOS/DIVERSOS");&lt;BR /&gt;DIVERSOS = DOCUMENTOS_INTERNOS.createFolder("DIVERSOS");&lt;BR /&gt;//var TESTES_E_AVALIACOES_DE_ADMISSAO = document.childByNamePath("DOCUMENTOS&amp;nbsp;INTERNOS/TESTES E AVALIACÕES DE ADMISSÃO");&lt;BR /&gt;TESTES_E_AVALIACOES_DE_ADMISSAO = DOCUMENTOS_INTERNOS.createFolder("TESTES E AVALIACÕES DE ADMISSÃO");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;DOCUMENTOS_INTERNOS.setInheritsPermissions(false);&lt;BR /&gt;DOCUMENTOS_INTERNOS.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;DOCUMENTOS_INTERNOS.setPermission("Consumer", nome);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var DOCUMENTOS_PESSOAIS = document.childByNamePath("DOCUMENTOS&amp;nbsp;PESSOAIS");&lt;BR /&gt;if ( DOCUMENTOS_PESSOAIS == null &amp;amp;&amp;amp; space.hasPermission("CreateChildren"))&lt;BR /&gt;{&lt;BR /&gt;// create DOCUMENTOS&amp;nbsp;PESSOAIS with some subfolders&lt;BR /&gt;DOCUMENTOS_PESSOAIS = document.createFolder("DOCUMENTOS&amp;nbsp;PESSOAIS");&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;var DOCUMENTOS_DEPENDENTES = document.childByNamePath("DOCUMENTOS&amp;nbsp;PESSOAIS/DOCUMENTOS DOS DEPENDENTES");&lt;BR /&gt;DOCUMENTOS_DEPENDENTES = DOCUMENTOS_PESSOAIS.createFolder("DOCUMENTOS DOS DEPENDENTES");&lt;BR /&gt;var DOCUMENTOS_DO_CONJUGE = document.childByNamePath("DOCUMENTOS&amp;nbsp;PESSOAIS/DOCUMENTOS DO CÔNJUGE");&lt;BR /&gt;DOCUMENTOS_DO_CONJUGE = DOCUMENTOS_PESSOAIS.createFolder("DOCUMENTOS DO CÔNJUGE");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;else {&lt;BR /&gt;var DOCUMENTOS_DEPENDENTES = document.childByNamePath("DOCUMENTOS&amp;nbsp;PESSOAIS/DOCUMENTOS DOS DEPENDENTES");&lt;BR /&gt;DOCUMENTOS_DEPENDENTES = DOCUMENTOS_PESSOAIS.createFolder("DOCUMENTOS DOS DEPENDENTES");&lt;BR /&gt;var DOCUMENTOS_DO_CONJUGE = document.childByNamePath("DOCUMENTOS&amp;nbsp;PESSOAIS/DOCUMENTOS DO CÔNJUGE");&lt;BR /&gt;DOCUMENTOS_DO_CONJUGE = DOCUMENTOS_PESSOAIS.createFolder("DOCUMENTOS DO CÔNJUGE");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;DOCUMENTOS_PESSOAIS.setInheritsPermissions(false);&lt;BR /&gt;DOCUMENTOS_PESSOAIS.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;DOCUMENTOS_PESSOAIS.setPermission("Consumer", nome);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;var ESPELHO = document.childByNamePath("ESPELHO&amp;nbsp;DE&amp;nbsp;PONTO");&lt;BR /&gt;if ( ESPELHO== null &amp;amp;&amp;amp; space.hasPermission("CreateChildren"))&lt;BR /&gt;{&lt;BR /&gt;// create Documentazione with some subfolders&lt;BR /&gt;ESPELHO = document.createFolder("ESPELHO&amp;nbsp;DE&amp;nbsp;PONTO");&lt;BR /&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;ESPELHO.setInheritsPermissions(false);&lt;BR /&gt;ESPELHO.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;ESPELHO.setPermission("Consumer", nome);&lt;/P&gt;&lt;P&gt;var FERIAS = document.childByNamePath("FÉRIAS");&lt;BR /&gt;if ( FERIAS== null &amp;amp;&amp;amp; space.hasPermission("CreateChildren"))&lt;BR /&gt;{&lt;BR /&gt;// create Documentazione with some subfolders&lt;BR /&gt;FERIAS = document.createFolder("FÉRIAS");&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;FERIAS.setInheritsPermissions(false);&lt;BR /&gt;FERIAS.setPermission("Coordinator", "GROUP_RHF");&lt;BR /&gt;FERIAS.setPermission("Consumer", nome);&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 20:13:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/automatic-folder-creation/m-p/137966#M37008</guid>
      <dc:creator>CRISTIAN_MULLER</dc:creator>
      <dc:date>2021-04-16T20:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Folder creation</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/automatic-folder-creation/m-p/137967#M37009</link>
      <description>&lt;P&gt;If i understood the question, you want to upload content to a path. You can make use of rest apis, see a solution here:&amp;nbsp;&lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-forum/i-want-to-add-a-document-in-a-subdirectory/m-p/298399#M19034" target="_blank" rel="nofollow noopener noreferrer"&gt;https://hub.alfresco.com/t5/alfresco-content-services-forum/i-want-to-add-a-document-in-a-subdirectory/m-p/298399#M19034&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Or&amp;nbsp;With help of root folder you can look for existance of subfolder and if doesn't exist you can create them. For example&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you have a root folder Asset in document library and you want to create content in Asset/docs/test, then using the webscript/script/ you can search for the subfolder using tmdq search api and then create the path and upload the content.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example in java for creating folders based on path;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-create-directory-structure-using-java-api/m-p/303068/highlight/true#M21989" target="_blank" rel="nofollow noopener noreferrer"&gt;https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-create-directory-structure-using-java-api/m-p/303068/highlight/true#M21989&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 06:54:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/automatic-folder-creation/m-p/137967#M37009</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2021-04-30T06:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Automatic Folder creation</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/automatic-folder-creation/m-p/137968#M37010</link>
      <description>&lt;P&gt;Thanks for the answer, i have this scrit that runs wherever any folder are created in this workspace, the script runs automatically trough folder rules and works fine, except when the destination folder already exists, I give a look at source code of the page itself and notice that even that apears to have 2 folders with the same name (impossible with alfresco rules), turns out that the source code for the folder tiltle has a '&amp;amp;nbsp' caracter in spaces, so when my script compares the two folders name "ATESTADOS MÉDICOS" with&amp;nbsp;"ATESTADOS&amp;amp;nbspMÉDICOS", visually they are the same because html puts a space at '&amp;amp;nbsp' location, when my script compares they are not the same.&lt;/P&gt;&lt;P&gt;Now I Have two change all the&amp;nbsp; '&amp;amp;nbsp' im my folders name.&lt;/P&gt;&lt;P&gt;Someone has an idea how to acomplish that?.&lt;/P&gt;</description>
      <pubDate>Fri, 14 May 2021 16:47:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/automatic-folder-creation/m-p/137968#M37010</guid>
      <dc:creator>CRISTIAN_MULLER</dc:creator>
      <dc:date>2021-05-14T16:47:15Z</dc:date>
    </item>
  </channel>
</rss>

