Can you make .lnk file date same as its target

English support forum

Moderators: Hacker, petermad, Stefan2, white

sorcar
Member
Member
Posts: 100
Joined: 2005-04-12, 17:45 UTC
Location: U.S.

Can you make .lnk file date same as its target

Post by *sorcar »

TC can do multiple .lnk files from selected files by Ctrl+Shift+F5, but their datestamps are the date and time of making the links. I could not find a way in TC or its plugins how to reflect in .lnk files the date of their target files. Can anyone suggest a way, either in TC, or through any other programs to achieve this?
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

See "Files > Change Attributes"







.
sorcar
Member
Member
Posts: 100
Joined: 2005-04-12, 17:45 UTC
Location: U.S.

Post by *sorcar »

Tried. That requires me to change each of file date manually to match the date of the target file. I need to make thousands of .lnk files for classifying docs to different organizational folders, but they do not reflect the datestamps of the target files. I was looking for some help on how to automate the process. Thanks in anticipation.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

sorcar,
If you will access these files from TC, you can try my Virtual Panel plugin in order to keep links to files. It always shows actual attributes of linked files.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,
Perhaps you could make hardlinks?

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
sorcar
Member
Member
Posts: 100
Joined: 2005-04-12, 17:45 UTC
Location: U.S.

Post by *sorcar »

MVV: Good workaround suggestion, will try this first. I wished though someone might write a DOS, or AHK script...
Hacker: I thought of this, but hard links often turn into separate files during copying and backup operations.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,
Just say the word ;)

Code: Select all

Loop, Read, %1%
{
	SplitPath, A_LoopReadLine, FileName
	FileGetTime, TimeStamp, %A_LoopReadLine%
	FileCreateShortcut, %A_LoopReadLine%, %2%%FileName%.lnk
	FileSetTime, %TimeStamp%, %2%%FileName%.lnk
}
Create CreateLinksKeepingTimestamps.ahk with the above contents, add to Button Bar, set

Code: Select all

"%L" "%T\"
as the parameters, select source files, click button and links to the source files will be created in the target dir having their timestamps adjusted automatically.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
sorcar
Member
Member
Posts: 100
Joined: 2005-04-12, 17:45 UTC
Location: U.S.

Post by *sorcar »

Hacker: Works like a charm. Many, many, many thanks.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,
Welcome. :) You can also create a user command that would call this script and assign it to a keyboard shortcut such as Ctrl-Shift-F5, overriding the default TC shortcut to create links.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
sorcar
Member
Member
Posts: 100
Joined: 2005-04-12, 17:45 UTC
Location: U.S.

Post by *sorcar »

That is great. One issue: the code now adds the extension as part of the name before .lnk (such as letter.doc.lnk). Is there a way to have the filename only in the shortcut? (Not a big issue though).
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,
TC does that, too. :P Here is the adjusted code:

Code: Select all

Loop, Read, %1%
{
	SplitPath, A_LoopReadLine, , , , FileName
	FileGetTime, TimeStamp, %A_LoopReadLine%
	FileCreateShortcut, %A_LoopReadLine%, %2%%FileName%.lnk
	FileSetTime, %TimeStamp%, %2%%FileName%.lnk
}
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
sorcar
Member
Member
Posts: 100
Joined: 2005-04-12, 17:45 UTC
Location: U.S.

Post by *sorcar »

Roman: Works great! Will you please put this on TotalcmdWiki AHK scripts, please? That page contains quite a few useful scripts, many contributed by you, but has not been updated this year.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,
Sure, done. :)

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
sorcar
Member
Member
Posts: 100
Joined: 2005-04-12, 17:45 UTC
Location: U.S.

.lnk files for selected files and files within selected dirs

Post by *sorcar »

Additional feature request [after almost 3 years]:

The ahk code above makes shortcuts for selected files - but does not include files within selected folders. Can someone show how to make shortcuts of all selected files, including those inside selected directories (recursively)?

Thanks in advance.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,
Like this?

Code: Select all

Loop, Read, %1%
{
	FileGetAttrib, Attrib, %A_LoopReadLine%
	IfInString, Attrib, D
	{
		Loop, Files, %A_LoopReadLine%*.*, R
		{
			SplitPath, A_LoopFileLongPath, , , , FileName
			FileGetTime, TimeStamp, %A_LoopFileLongPath%
			FileCreateShortcut, %A_LoopFileLongPath%, %2%%FileName%.lnk
			FileSetTime, %TimeStamp%, %2%%FileName%.lnk
		}
		Continue
	}

	SplitPath, A_LoopReadLine, , , , FileName
	FileGetTime, TimeStamp, %A_LoopReadLine%
	FileCreateShortcut, %A_LoopReadLine%, %2%%FileName%.lnk
	FileSetTime, %TimeStamp%, %2%%FileName%.lnk
}
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Post Reply