Skip to main content
Participant
June 20, 2022
Question

Why file.modified failed to get file modified date (jsx)

  • June 20, 2022
  • 4 replies
  • 532 views

In JSX script, I can use file.modified gets the modified date of the file, but displays null on MacOS

This topic has been closed for replies.

4 replies

jduncan
Community Expert
Community Expert
September 13, 2022

Pretty sure the .modified() method is just broken on the Mac for whatever reason. We discussed it here as well.

Participant
September 13, 2022

I too am getting this issue, after trying a lot of things and trying to get an answer through searching online, I have arrived here.

 

I have code that works for InDesign but errors with Illustrator for getting a modified date for a file

 

Full File Path obscured, but catch never fires off anyways as the $.fileName returns correctly

try{
   var CurrentScript = File($.fileName)
} catch (err) {
   var CurrentScript = File("/Users/Folders.../ScriptName.jsx")
}
alert(CurrentScript.exists + "\n" + CurrentScript.modified)
 
Here are the results to the alert. indesign sees the file and returns the modification date.
Illustrator sees the file but returns null for some reason. Anyone have any insight into this?
femkeblanco
Legend
June 20, 2022

It works for me (Windows).  If you're getting "null", then the file is not being accessed.  Try the full path?

Dodo BirdAuthor
Participant
June 21, 2022

It works in Windows,but getting "null" in macos

renél80416020
Inspiring
June 21, 2022

 

Dodo BirdAuthor
Participant
June 20, 2022

my jsx like this:

 

#target "illustrator"
#targetengine "main"

var myFolder = File("~/Desktop");
var myFiles = new File(myFolder.getFiles("test.ai"));
var myFileDate = myFiles.modified;
alert(myFileDate);

renél80416020
Inspiring
June 20, 2022

Bonjour,

Le chemin est bien /Users/Desktop  ?

var myFolder = "~/Desktop";
var myFiles = new File(myFolder+"/test.ai");
alert(myFiles.exists)
var myFileDate = myFiles.modified;
alert(myFileDate);
var myFileDate = myFiles.created;
alert(myFileDate);