Skip to main content
jasonp49818280
Inspiring
June 30, 2022
Question

file.modified always returns null

  • June 30, 2022
  • 1 reply
  • 485 views

No matter what I do, I always have the modified returned as null. I am trying to get the modified date of two different files, and if the file is older then then server version it replaces the the older one with the new one. (Making something to update all our team scripts instead of me sending out a new JSX file and instructions each time)

 

here is the super simple code I am using to test though

 

var myFile = File ("~/Desktop/Test.png")
$.writeln("Is File: " + String(myFile instanceof File))
$.writeln("Exist: " + String(myFile.exists))
$.writeln("modified: " + String(File( myFile).modified));
 
and my results are
Is File: true
Exist: true
modified: null
 
any idea why its doesnt think its a file?
This topic has been closed for replies.

1 reply

CarlosCanto
Community Expert
Community Expert
July 1, 2022

I used 

$.writeln("modified: " + myFile.modified);

 

Is File: true
Exist: true
modified: Fri Apr 02 2021 19:09:24 GMT-0700

 

but your script also worked as is

 

(I'm on Windows)

jduncan
Community Expert
Community Expert
July 1, 2022

I tried this on my Mac and it returns null. I even checked the file properties in the VS Code debugger and both `created` and `modified` are null.  I set a file as a var and also picked a file using `openDialog()` and got the same results. Seems, it may be implemented on Windows but not on Mac.

CarlosCanto
Community Expert
Community Expert
July 1, 2022

or perhaps Mac changed their file system again