Skip to content

CollectionPaths in user wildcards for sub-folder renaming#544

Open
josephgarnier wants to merge 1 commit into
jlegewie:masterfrom
josephgarnier:collectionpaths-in-user-wildcards
Open

CollectionPaths in user wildcards for sub-folder renaming#544
josephgarnier wants to merge 1 commit into
jlegewie:masterfrom
josephgarnier:collectionpaths-in-user-wildcards

Conversation

@josephgarnier

Copy link
Copy Markdown

Currently for a "rename and move" action, it is not possible to apply an operation on the CollectionPaths field in a user-defined wildcard.
For example, let's say I have this configuration:
00

and these wildcards:

{
  "1": {
    "default": {
      "field": "title",
      "operations": [
        {
          "function": "replace",
          "regex": "[\\:|\\,|\\.]",
          "replacement": ""
        },
        {
          "function": "replace",
          "regex": "[\\']",
          "replacement": "_"
        }
      ]
    }
  },
  "2": {
    "default": {
      "field": "collectionPaths",
      "operations": [
        {
          "function": "replace",
          "regex": "[\\s]",
          "replacement": "_"
        }
      ]
    }
  }
}

Normally with the wildcard number 2, it is expected that the attached file that is in the collection 3_Resources/Economics Finance Business and Management/Business and Management/Management and Management Techniques/Knowledge Management will be renamed and then moved to the folder<root>/3_Resources/Economics_Finance_Business_and_Management/Business_and_Management/Management_and_Management_Techniques/Knowledge_Management by replacing the spaces by _.

Here, in pictures, the structure of the collections and the expected result:
01
02

However, since the function wildcardTable(item) function in wildcards.js expects to work only with fields containing strings and not objects (as is the case with the CollectionPaths field, which is an array), the replace is not a function error occurred. This patch fixes that.

The field CollectionPaths can now be used in user wildcards for sub-folders renaming
@raphaelhuleux

Copy link
Copy Markdown

Hey, just mentioning that I have the same issue. I'm trying to organize my files according to the user-specifief wildcard:

"2": { "default": { "field": "collectionPaths", "operations": [ { "function": "replace", "regex": "(^|\\s+|_+|\\/)(\\w{1})(?![nd|r]{1})", "replacementFunction": { "arguments": [ "match", "g1", "g2", "offset", "string" ], "body": "return g1.concat(g2.toUpperCase());" } } ] }

without success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants