Script: Modifying NewPath

Advanced Renamer forum
#1 : 07/06-19 10:44
John
John
Posts: 10
In a script to import camera images I would like to add a check on the output folder, to ensure that it has a trailing '\", if not then I add one.
At the moment I solved this by checking NewPath for every item processed, using
item.newPath = item.newPath.replace(/\\?$/, '\\');
but I would prefer to do it only once in the pre-batch script as I assume it would be slightly quicker.

Is 'output folder' available as via app.?

Also, is there a summary of the app. & item. methods with a little more detail? Most are fairly obvious but some are less clear, eg item.newNameOverride.

John


07/06-19 10:44 - edited 07/06-19 10:47
#2 : 08/06-19 18:27
David Lee
David Lee
Posts: 261
I'm not sure exactly what you are trying to do overall - however you could set a variable to your path in the pre batch script on the basis of the first item in the list and then use this variable to set the newPath for individual items in the main script. eg ...

myPath = app.getItem(0).newPath.replace(/\\?$/, '\\');

Then use this variable to set the newPath for individual items in the main script.

That should reduce the number of program steps and may speed up processing.

However, unless you wish subsequently to append characters to the result, do you really need to check for the terminal "/"? Renamer appears to add this to the path string automatically if it is absent.

Re item.newNameOverride - it's a mystery! It's set to null by default and doesn't appear to do anything if it's changed.





08/06-19 18:27
#3 : 09/06-19 11:29
John
John
Posts: 10
Reply to #2: The 'output folder' value is just the root of my destination path. I will append the camera name, and for certain image types an additional suffix and count for bracketed shots (eg HDR, focus stacking, panorama) so they are easier to identify for post-processing.

My first version assumed the '\' would be present but I prefer to check.

Your solution is clear, should have thought of that, thanks very much:-)
John


09/06-19 11:29
#4 : 09/06-19 12:37
John
John
Posts: 10
Reply to #3: Just noticed your other comment "Renamer appears to add this to the path string automatically if it is absent".

I just ran a test and this isn't the case, if I omit the trailing \ it's missing in the final path after I append. Could it be that it only adds a missing \ for non-script methods?


09/06-19 12:37
#5 : 09/06-19 23:32
David Lee
David Lee
Posts: 261
Reply to #4:
I did say "unless you wish subsequently to append characters to the result...". Renamer appears to add the "\" automatically to the end of the path when running a move/copy batch. However you will need to add it manually if you are appending nodes to the path string.


09/06-19 23:32
#6 : 10/06-19 10:30
John
John
Posts: 10
Reply to #5:
All clear David, thanks for the clarification. The script is complete now.

John


10/06-19 10:30
#7 : 10/06-19 14:40
David Lee
David Lee
Posts: 261
Reply to #6:
Glad it's working John.

Thanks very much for posting your query - as a result of tinkering with your problem I've learned a lot about scripting in Renamer that I previously wasn't aware of.


10/06-19 14:40
#8 : 10/06-19 16:36
John
John
Posts: 10
Reply to #7:
I thought about uploading the script in case it's useful for anyone but I'm not sure what the best solution would be. I could share a Dropbox folder I suppose.
I also need to add some documentation (never my strength)


10/06-19 16:36