Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Data Merge: CSV Random Order Issue

Explorer ,
Feb 23, 2025 Feb 23, 2025

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:

Screenshot 2025-02-23 at 3.22.07 PM.pngexpand image

 

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.

TOPICS
Import and export , Scripting

Views

205
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Feb 25, 2025 Feb 25, 2025

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

...

Votes

Translate
Community Expert ,
Feb 23, 2025 Feb 23, 2025

Copy link to clipboard

Copied

How do you produce this CSV file? What is "this script"? 

 

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2025 Feb 24, 2025

Copy link to clipboard

Copied

Think they are talking about the image catalog script. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2025 Feb 24, 2025

Copy link to clipboard

Copied

quote

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?

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2025 Feb 24, 2025

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/

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 24, 2025 Feb 24, 2025

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2025 Feb 24, 2025

Copy link to clipboard

Copied

@Mariano–

 

ImageCatalog just place files - it doesn't create a CSV file? 

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 24, 2025 Feb 24, 2025

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2025 Feb 24, 2025

Copy link to clipboard

Copied

@Mariano–

 

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. 

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 24, 2025 Feb 24, 2025

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 25, 2025 Feb 25, 2025

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.

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2025 Feb 25, 2025

Copy link to clipboard

Copied

@Mariano– 

 

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.

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2025 Feb 25, 2025

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());
});

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 25, 2025 Feb 25, 2025

Copy link to clipboard

Copied

LATEST

APFS changed the order of files delivered by the operating system.

Sort the result if you depend on a specific order.

 

https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/F...

  • Calling readdir(2) on a directory in APFS returns filenames in hash order, whereas HFS+ returns filenames in lexicographical order.

 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines