Issue with CSV Access in Script Method (app.csvRowCount Undefined)

#1 : 08/07-25 08:12
Saad
Posts: 3
Hallo,
I am using Advanced Renamer version 4.13 (Free / Not Registered), and I’m encountering an issue with the scripting engine when trying to use the Pre Batch Script method in combination with CSV import.

The CSV is correctly imported (I can verify it with <Csv:2> tag and New Name method), but in the Pre Batch Script, the `app.csvRowCount` and `app.getCsvValue()` functions are returning `undefined`.

Steps I followed:
- Loaded a valid UTF-8 CSV with `;` as separator
- Used the CSV tag <Csv:2> in "New Name" method — it works fine
- Tried to populate a JS object in Pre Batch Script using:

```javascript
var csvMap = {};
for (var i = 0; i < app.csvRowCount; i++) {
var key = app.getCsvValue(i, 0);
var value = app.getCsvValue(i, 1);
csvMap[key] = value;
}
Thanks in Advance
#2 : 08/07-25 09:07
Kim Jensen
Administrator
Posts: 1000
Reply to #1:
There are no such methods. app.csvRowCount and app.getCsvValue are not methods of Advanced Renamer. Where did you see those?

You can use the CSV tags in the same way as you do in New Name method, like this:

return app.parseTags('<CSV:10>');


FYI: I am planning to make it easier to use external data sources in scripting.
#3 : 08/07-25 09:09
Delta Foxtrot
Posts: 519
Reply to #2:

Kim: AWESOME! (raising wine glass in toast)

Congrats on post 1000, BTW.

Saad: if you search the forum there are some earlier posts about using CSVs, they were a great help to me. You can probably find them just by searching on "csv".

If you load a csv in the pre-batch script as an array it's relatively "easy" to deal with situations like you are describing.

Best,
DF

edited: 08/07-25 09:18
#4 : 08/07-25 09:31
Saad
Posts: 3
Reply to #2:

Hi Kim,

Thank you very much for the quick reply...I'm new to Advanced Renamer and I'm looking for a list of script methods with CSV, but I can't find it. So I tried asking Chatgpt, and the answer was this method

Best regards
#5 : 08/07-25 09:37
Saad
Posts: 3
Reply to #3:

Hi DF,

Thanks for the tip – I will definitely check out the previous posts on CSVs.

Best regards
#6 : 08/07-25 10:45
Chris
Posts: 36
Reply to #4:

> So I tried asking Chatgpt

Thanks for the warning! :)

Sorry I can't suggest a solution. Good luck!

edited: 08/07-25 10:48