Page 1 of 1

How to change a file’s last modified on Mac OSX

Posted: Wed Jan 02, 2013 12:42 pm
by adeam
Hello,

I'm new with Mac OSX and Live Code and would like to know how to change a file’s last modified on Mac OSX. I tried the command below but it seems it doesn't work:

- launch touch -mt 201201010000 "/Users/me/Documents/test.html" with "/Applications/Utilities/Terminal.app"

Could you kindly help me.

Thanks. :P

Re: How to change a file’s last modified on Mac OSX

Posted: Wed Jan 02, 2013 2:18 pm
by Klaus
Hi adeam,

you need to use the SHELL function to fire the actual terminal command like this:
...
put "/Users/me/Documents/test.html" into tFile2Touch
get shell("touch -mt 201201010000" && tFile2Touch)
...
You may need to escape the filename if it contains spaces etc.


Best

Klaus

Re: How to change a file’s last modified on Mac OSX

Posted: Thu Jan 03, 2013 4:14 pm
by adeam
Thanks Klaus :D and happy new year :!:

Concerning escape the filename if it contains spaces, is that applicable to folder names with spaces as well?

...
put "/Users/me/Documents/test v1/test with spaces.html" into tFile2Touch
get shell("touch -mt 201201010000" && tFile2Touch)
...

Thanks again.

Re: How to change a file’s last modified on Mac OSX

Posted: Thu Jan 03, 2013 4:43 pm
by Klaus
I think QUOTING your filenames for using with SHELL will do.

Code: Select all

...
put QUOTE & "/Users/me/Documents/test v1/test with spaces.html" & QUOTE into tFile2Touch
get shell("touch -mt 201201010000" && tFile2Touch)
...
I always have a little function for this in my stackscript:

Code: Select all

function q tString
  return QUOTE & tString & QUOTE
end q
Use it like this (very handy and timesaving :D ):

Code: Select all

...
put q("/Users/me/Documents/test v1/test with spaces.html") into tFile2Touch
get shell("touch -mt 201201010000" && tFile2Touch)
...
Best

Klaus

Re: How to change a file’s last modified on Mac OSX

Posted: Thu Jan 03, 2013 4:51 pm
by adeam
Thanks a lot Klaus. :D
Adding QUOTE works perfectly. As well as using the function you've wrote. :D
...
put QUOTE & "/Users/me/Documents/test v1/test with spaces.html" & QUOTE into tFile2Touch
get shell("touch -mt 201201010000" && tFile2Touch)
...

Cheers. :D :lol: :P :) :mrgreen: