I would like to create and move each file to a nomenclar folder
Hi everyone,
I have some files e.g. : rl102c36.jpg and I would like to create and move each file to a nomenclar folder with the first 5 characters. In detail the file rl102c36.jpg will be placed in the folder RL102 in uppercase.
Can you help me?
Thank you very much for your cooperation.
Ronald
I have some files e.g. : rl102c36.jpg and I would like to create and move each file to a nomenclar folder with the first 5 characters. In detail the file rl102c36.jpg will be placed in the folder RL102 in uppercase.
Can you help me?
Thank you very much for your cooperation.
Ronald
Reply to #1:
Under normal circumstances you should be able to use the "Move" batch mode with the Output field set to "<Substr:1:5:upper>, but Kim's still working some kinks out of the tags system that he recently reworked, so in the meantime here's a script that will do what you want. Just copy and paste what's between the lines starting with "//" into a Script method with no other methods in the list, press "Apply script", add your files, and you should get your files where you want them. Before you do, though, I suggest you make the "new path" column visible if it's not (press the "Column" button); that way you can see where your files will end up. Also remember you can undo any batch if you don't get what you want.
// ----------------------------------------------------
n = item.newBasename ;
p = item.path ;
np = p + n.slice( 0, 5 ).toUpperCase() ;
item.newPath = np ;
// ----------------------------------------------------
Best,
DF
Under normal circumstances you should be able to use the "Move" batch mode with the Output field set to "<Substr:1:5:upper>, but Kim's still working some kinks out of the tags system that he recently reworked, so in the meantime here's a script that will do what you want. Just copy and paste what's between the lines starting with "//" into a Script method with no other methods in the list, press "Apply script", add your files, and you should get your files where you want them. Before you do, though, I suggest you make the "new path" column visible if it's not (press the "Column" button); that way you can see where your files will end up. Also remember you can undo any batch if you don't get what you want.
// ----------------------------------------------------
n = item.newBasename ;
p = item.path ;
np = p + n.slice( 0, 5 ).toUpperCase() ;
item.newPath = np ;
// ----------------------------------------------------
Best,
DF
Reply to #2:
Hi guys,
The <Substr:1:5> tag works fine in version 4.18 .
https://i.postimg.cc/MZYsDNCg/Img-081.png
Have a good day
Hi guys,
The <Substr:1:5> tag works fine in version 4.18 .
https://i.postimg.cc/MZYsDNCg/Img-081.png
Have a good day
Reply to #1:
Hello!
Delta Foxtrot's method works but here is a slightly more robust version to use as a script method:
//-------------------------------------------------------------
folderBase = item.path; //-- Subdirs from where the file currently is
//folderBase = "C:\\temp\\del_me\\"; //-- Subdirs in the specified directory
newSubDir = item.newBasename.replace (/^([a-z]+?\d+).+$/, "$1").toUpperCase ();
item.newPath = folderBase + newSubDir
//-------------------------------------------------------------
This is in case the directory name is not always the first 5 characters. You can easily adjust the regex as necessary.
Here, I assume the the pattern is some number of initial letters, followed by some number of digits.
Edit: Oopsie! Apparently Aren JS doesn't handle paths as well as Aren move does. Fixed code ;)
Hello!
Delta Foxtrot's method works but here is a slightly more robust version to use as a script method:
//-------------------------------------------------------------
folderBase = item.path; //-- Subdirs from where the file currently is
//folderBase = "C:\\temp\\del_me\\"; //-- Subdirs in the specified directory
newSubDir = item.newBasename.replace (/^([a-z]+?\d+).+$/, "$1").toUpperCase ();
item.newPath = folderBase + newSubDir
//-------------------------------------------------------------
This is in case the directory name is not always the first 5 characters. You can easily adjust the regex as necessary.
Here, I assume the the pattern is some number of initial letters, followed by some number of digits.
Edit: Oopsie! Apparently Aren JS doesn't handle paths as well as Aren move does. Fixed code ;)
Reply to #3:
Hi Styb,
You're right, <Substr:1:5> works fine, but Ronald wants the folder name to have the first five characters of the filename in uppercase. As I said, <Substr:1:5:upper> *should* work but doesn't convert to upper case. Neither does <Substr:1:5:upper:1:5>.
Best,
DF
Hi Styb,
You're right, <Substr:1:5> works fine, but Ronald wants the folder name to have the first five characters of the filename in uppercase. As I said, <Substr:1:5:upper> *should* work but doesn't convert to upper case. Neither does <Substr:1:5:upper:1:5>.
Best,
DF
Reply to #5:
The Substr-tag is a little special in regards to tag modifiers. They only work when all parameters of Substr is used, and that tag has an extra optional parameter.
This will work:
<Substr:1:5:1:upper>
This will also work
<Name:substr:1:5:upper>
The definition for Substr is:
<Substr:pos:count:start>
Where the "start" parameter is optional.
The Substr-tag is a little special in regards to tag modifiers. They only work when all parameters of Substr is used, and that tag has an extra optional parameter.
This will work:
<Substr:1:5:1:upper>
This will also work
<Name:substr:1:5:upper>
The definition for Substr is:
<Substr:pos:count:start>
Where the "start" parameter is optional.
Reply to #6:
Thanks for the clarification Kim, that helps.
Thanks for the clarification Kim, that helps.
Reply to #6:
That's great to know, Kim.
But is that documented in the guide? I missed it but my eyes are not the best... ;)
That's great to know, Kim.
But is that documented in the guide? I missed it but my eyes are not the best... ;)
Reply to #8:
Which one? Substr having a third less known parameter or that tag modifiers for substr only works when all parameters are used?
The answer to first is yes, the answer to the second is probably not.
The third parameter of Substr can be a string instead of a number, which makes it difficult to distinguish between "upper" the text and "upper" the tag modifier.
For other tags, like the <IncNr> which supports two parameters, you can use tag modifiers instead of the second parameter. That is because it only supports numbers for its parameters. I know this seems confusing and inconsistent. But so is life.
Which one? Substr having a third less known parameter or that tag modifiers for substr only works when all parameters are used?
The answer to first is yes, the answer to the second is probably not.
The third parameter of Substr can be a string instead of a number, which makes it difficult to distinguish between "upper" the text and "upper" the tag modifier.
For other tags, like the <IncNr> which supports two parameters, you can use tag modifiers instead of the second parameter. That is because it only supports numbers for its parameters. I know this seems confusing and inconsistent. But so is life.
Reply to #9:
Yes, the second part. It would be nice to have it in the docs under modifiers, for future reference.
Note that 2 power users, plus myself, were not aware if this caveat. :D
Yes, the second part. It would be nice to have it in the docs under modifiers, for future reference.
Note that 2 power users, plus myself, were not aware if this caveat. :D