Copy link to clipboard
Copied
Why would the CSV file used in Data Merge when auto-importing images from a folder be ordered randomly?
I have a folder of images named: SEP 01.psd, SEP 02.psd, SEP 03.psd, etc. but the resulting CSV after running the script looks like this:
I know I can re-order the CSV file but I want to know why is this happening because I've used this script extensively in the past with no problems. I've tried all 3 formats of the ImageCatalog script included in InDesign, plus a custom version I always use, and they all yield the same unordered results.
1 Correct answer
Thanks to Robert at ID-Tasker mentioning NTFS and file creation order, I've found the source of the problem: it's a file naming and disk format combination issue, not an InDesign or script-related problem
Robert's comment made me take a closer look into disk formats and the files themselves, as everything else seemed right. So I've discovered that even though the files are numbered sequentially in ascending order, they come up arranged by modification date on the resulting CSV. I copied the file
...Copy link to clipboard
Copied
How do you produce this CSV file? What is "this script"?
Copy link to clipboard
Copied
Think they are talking about the image catalog script.
Copy link to clipboard
Copied
Think they are talking about the image catalog script.
By brian_p_dts
I just checked - just in case 😉 - but I don't see anywere in the ImageCatalog script option to export CSV file?
Copy link to clipboard
Copied
Guess you're using a mac. What version of the OS is running? Guessing you've run this script before with the list in the correct order - do you recall when the last time the script ran correctly?
I don't think the script is creating the list randomly, but just in a different order (possibly date made or file size, I can't tell from here).
When I have a look at the imagecatalog.jsx script in a text editor, I can see that line 59 is the mac file filter. It is literally building an array (a list of stuff) but there isn't an instruction as to how to sort that stuff, so the script may be using whatever sort order is currently active in your finder.
Perhaps try an alternative script, such as the two image folder to data merge scripts from Ozalto's website http://www.ozalto.com/en/solutions-en/downloads/
Copy link to clipboard
Copied
Thank you for your replies. The script I'm referring to is called ImageCatalog, it's included in the Mac version of InDesign and it comes in AppleScript, JavaScript and UXPScript formats.
I've just tried a similar script from Ozalto linked above by Colin (Folder2CSV) and the non-sequential order still persists. Since all formats are failing, I'm going to look into the image files themselves. Perhaps there's a file related property generating this error.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That's true, the CSV is created by a custom script akin to the one offered by Ozalto. But when using ImageCatalog the images are being placed in the same wrong order as they appear on the CSV file.
Copy link to clipboard
Copied
Yes, because no sort order has been "forced".
Files are just populated by - most likely - order of creation - when system finished writing to the file and "closed" it.
Or just an order in the "master file table" - for NTFS.
Copy link to clipboard
Copied
Hi @Mariano– can you post the script that generates the CSV file? I suspect it would be easy to fix it.
- Mark
Copy link to clipboard
Copied
Thanks to Robert at ID-Tasker mentioning NTFS and file creation order, I've found the source of the problem: it's a file naming and disk format combination issue, not an InDesign or script-related problem
Robert's comment made me take a closer look into disk formats and the files themselves, as everything else seemed right. So I've discovered that even though the files are numbered sequentially in ascending order, they come up arranged by modification date on the resulting CSV. I copied the files from the external PC-formatted drive they originally reside into a new folder on my Mac, renamed all files sequentially again –making sure they are ordered by name and not by creation or modification date– and they are being imported correctly in numbered sequence now.
Copy link to clipboard
Copied
Always happy to help 🙂
But this could be corrected in the script - by forcing sort order, either when files as accessed - in ImageCatalog script - or the whole list can be sorted before being saved as CSV file.
Copy link to clipboard
Copied
Robert is right, this is something that should be fixed in the code. Something like this:
var files = myFolder.getFiles();
files.sort(function(a, b) {
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
});
Copy link to clipboard
Copied
APFS changed the order of files delivered by the operating system.
Sort the result if you depend on a specific order.
Calling readdir(2) on a directory in APFS returns filenames in hash order, whereas HFS+ returns filenames in lexicographical order.

