How to know the File size

Explorer ,
Sep 16, 2022 Sep 16, 2022

Copy link to clipboard

Copied

I need to validate the file size with and without comression is not same . If same file is used both the times. Can anyone help me with jsx code for the same .

 

Thanks in advance !!

TOPICS
Scripting

Views

88

Likes

Translate

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 2 Correct answers

Community Expert , Sep 17, 2022 Sep 17, 2022

it works ok with open files in illustrator, Windows 11, CC2022

 

var idoc = app.activeDocument;
var f = idoc.fullName;

alert("Active Document size: " + f.length + " bytes")

fileSize.jpg

Likes

Translate

Translate
Advisor , Sep 17, 2022 Sep 17, 2022

@CarlosCanto  You're correct.  The file has to be saved (not closed).  An unsaved new file returns -1. 

Likes

Translate

Translate
Community Expert ,
Sep 16, 2022 Sep 16, 2022

Copy link to clipboard

Copied

Hi @Daksri,

JSX does not have any API to get the file size. Probably you could use batch/applescript launched from within JSX to do your comparison as returning data from these scripts back to jsx would again be a cumbersome task

-Manan

Likes

Translate

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
Advisor ,
Sep 16, 2022 Sep 16, 2022

Copy link to clipboard

Copied

The file object has a property called "length", which is the size of the file (in bytes).  To read, the file must not be open in Illustrator.  

Likes

Translate

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 ,
Sep 17, 2022 Sep 17, 2022

Copy link to clipboard

Copied

it works ok with open files in illustrator, Windows 11, CC2022

 

var idoc = app.activeDocument;
var f = idoc.fullName;

alert("Active Document size: " + f.length + " bytes")

fileSize.jpg

Likes

Translate

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
Advisor ,
Sep 17, 2022 Sep 17, 2022

Copy link to clipboard

Copied

@CarlosCanto  You're correct.  The file has to be saved (not closed).  An unsaved new file returns -1. 

Likes

Translate

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 ,
Sep 17, 2022 Sep 17, 2022

Copy link to clipboard

Copied

Thanks a lot for solving my query !!

 

Likes

Translate

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 ,
Sep 17, 2022 Sep 17, 2022

Copy link to clipboard

Copied

LATEST

Thanks a lot for solving my query !!

Likes

Translate

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