That would be nice if the Dir() XFcn would also return the last modification date of a folder in its result.
on mouseUp
local instr = dir(posixToHFS("~"), false, false, cr & tab, folders), outstr
set the itemdel to tab
repeat for each line aLine of instr
put item 1 of aline & tab & localizeDate(item 3 of aLine) & cr after outstr
end repeat
ask list outstr
end mouseUp
function localizeDate inDate
get inDate
convert it to international time
get last word of it
add char 1 of it & char 2 to 3 of it * 3600 + char 4 to 5 of it * 60 to inDate
convert inDate to abbr date and time
return ltrim(item 2 to 999 of inDate)
end localizeDate
on mouseUp
answer folder "Select a folder:"
if it is empty then exit script
get shell(merge("GetFileInfo -m `[[hfsToPosix(it)]]`"))
convert it to abbr date and time
put ltrim(item 2 to 999 of it)
end mouseUp
on mouseUp
answer folder "Select a folder:"
if it ≠ "" then answer shell("GetFileInfo -m" && bash_escape(hfsToPosix(it)))
end mouseUp
function bash_escape instr
return "'" & replace(instr, "'", "\'") & "'"
end bash_escape
Le 08-août-2019 à 01:49:06, 'codegreen' via SuperCard Discussion <superca...@googlegroups.com> a écrit :If you want to query a particular folder's mod date directly (rather than enumerating its contents) dir isn't really the right tool. You can do that easily enough using shell though:
Le 08-août-2019 à 06:02:52, 'codegreen' via SuperCard Discussion <superca...@googlegroups.com> a écrit :For posterity it should probably also be noted that using merge to wrap an arbitrary path in double quotes (while it makes for a nice simple example) is not a 'production code' solution, since any path containing double quotes will break it.Fortunately 'escaping' strings so they don't need to be quoted in shell commands is trivial (if non-obvious) in SuperTalk:
on mouseUp
answer folder "Yo:"
if it = "" then exit script
get shell(merge("stat -f `%m` -t `%c`") && bash_escape(hfsToPosix(it)))
answer shell(merge("date -jf `%s` `[[it]]` +`%d/%m/%Y %H:%M:%S`"))
end mouseUp
on mouseUp
answer folder "Yo:"
if it = "" then exit script
get shell("GetFileInfo -m" && bash_escape(hfsToPosix(it)))
answer shell(merge("date -jf `%m/%d/%Y %H:%M:%S` `[[it]]` +`%d/%m/%Y %H:%M:%S`"))
end mouseUp
There might be better ways, but you can use shell to do this manually for your local format:
on mouseUp
answer folder "Which the folder to check for its last modification?"
if it is not "Cancel" then
put FolderLastModSec(it) into Time01
put FolderLastModSec_Detailed(it) into Time02
answer "The last time this folder: " &RETURN&RETURN& it &RETURN&RETURN& ¬
"was modified in Mac HFS seconds, was:" &RETURN&RETURN& Time01
end if
end mouseUp
function FolderLastModSec HFSFolderPath
-- FolderLastModSec(HFSFolderPath) by Mark Lukas 20190808
--> Returns the time of the last modification to a folder in Mac HFS seconds format
put shell("GetFileInfo -m" && bash_escape(HFStoPosix(HFSFolderPath))) into the_result
put shell(merge("date -jf `%m/%d/%Y %H:%M:%S` `[[the_result]]` +`%d/%m/%Y %H:%M:%S`")) into the_result
convert the_result to seconds
return the_result
end FolderLastModSec
function bash_escape instr
return "'" & replace(instr, "'", "\'") & "'"
end bash_escape
-------
function FolderLastModSec_Detailed HFSFolderPath
-- FolderLastModSec_Detailed(HFSFolderPath) by Mark Lukas 20190808
--> Returns the time of the last modification to a folder in Mac HFS seconds format
-- Detailed script for educational purpose
-- trace
put HFStoPosix(HFSFolderPath) into POSIXFolderPath
put shell("GetFileInfo -m" && bash_escape(POSIXFolderPath)) into the_result1
put merge("date -jf `%m/%d/%Y %H:%M:%S` `[[the_result1]]` +`%d/%m/%Y %H:%M:%S`") into UnixShell2
put shell(UnixShell2) into the_result2
convert the_result2 to seconds
return the_result2
end FolderLastModSec_Detailed