Assume I have (under Win 7) a (log)file and (in another directory) a shortcut which points to this file.
Each original file and its shortcut have their own last modified timestamp (as shown in WinExplorer column).
Unfortunately when the original file is modified the timestamp of the depending shortcut file IS NOT modified too.
Is there a way to let the shortcut be touched as well?
There is no need of an immediate update of the last modified timestamp of the shortcut object.
It am searching for a DOS batch script which runs later over the whole partition, searches for shortcuts, compares their timestamp with the timestamp of their target files and uses a touch.exe command to adjust the shortcuts last modified timestamp acccordingly.
The batch script should work for folder shortcuts as well.
How can I implement such a batch script?
Peter
Update last modified time of shortcut when orig file is modf
Moderator: DosItHelp
Re: Update last modified time of shortcut when orig file is
You can check to see if a shortcut contains time related stamps of the target file/folder - TTBOMK they don't.
Re: Update last modified time of shortcut when orig file is
Your log and the shortcut are two different files. The time stamps of the shortcut are not updated because it was not changed.
It's not the answer to your question but you could read the target path out of the shortcut and determine its date last modified.
Save as batch file and drag/drop the shortcut onto it:
You could also execute the cscript line into a FOR /F loop to save the output in variables.
(the tokens may differ depending on your settings)
Regards
aGerman
It's not the answer to your question but you could read the target path out of the shortcut and determine its date last modified.
Save as batch file and drag/drop the shortcut onto it:
Code: Select all
@if (@X)==(@Y) @end /* line that initiates a JScript comment
:: Batch part:
@echo off &setlocal
cscript //e:jscript //nologo "%~f0" %*
pause
goto :eof
:: JScript part: */
try {
WScript.StdOut.WriteLine(WScript.CreateObject("Scripting.FileSystemObject")
.GetFile(WScript.CreateObject("WScript.Shell")
.CreateShortcut(WScript.Arguments.Item(0)).TargetPath)
.DateLastModified);
}
catch(e) {
WScript.StdErr.WriteLine(e.description);
}
You could also execute the cscript line into a FOR /F loop to save the output in variables.
Code: Select all
for /f "tokens=1*" %%i in ('cscript //e:jscript //nologo "%~f0" %*') do (
set "targetdate=%%i"
set "targettime=%%j"
)
(the tokens may differ depending on your settings)
Regards
aGerman