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.

Post by *sorcar »

Thanks Roman. Works flawlessly. But how to create equivalent folders and put the .lnk files into their respective folders in the target panel?
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,
Eh, you could have mentioned that before. :P

Code: Select all

Loop, Read, %1%
{
	FileGetAttrib, Attrib, %A_LoopReadLine%
	IfInString, Attrib, D
	{
		RegExMatch(A_LoopReadLine, ".*\\\K.*?(?=\\)", TopDirName)
		StringLen, SourceAbsolutePathLength, A_LoopReadLine
		SourceAbsolutePathLength--
		Loop, Files, %A_LoopReadLine%*.*, R
		{
			SplitPath, A_LoopFileLongPath, , SourceSubDirPath, , FileName
			StringTrimLeft, TargetSubDirPath, SourceSubDirPath, SourceAbsolutePathLength
			FileGetTime, TimeStamp, %A_LoopFileLongPath%
			FileCreateDir, %2%%TopDirName%%TargetSubDirPath%
			FileCreateShortcut, %A_LoopFileLongPath%, %2%%TopDirName%%TargetSubDirPath%\%FileName%.lnk
			FileSetTime, %TimeStamp%, %2%%TopDirName%%TargetSubDirPath%\%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.
sorcar
Member
Member
Posts: 100
Joined: 2005-04-12, 17:45 UTC
Location: U.S.

Code works.

Post by *sorcar »

Eh, you could have mentioned that before.
I was a little unsure if that would be possible. But it works so wonderfully!

Just show me one more thing. What change do I make to have filename.ext.lnk instead of filename.lnk. Both flavors (with or without extension) are useful.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,

Code: Select all

Loop, Read, %1%
{
   FileGetAttrib, Attrib, %A_LoopReadLine%
   IfInString, Attrib, D
   {
      RegExMatch(A_LoopReadLine, ".*\\\K.*?(?=\\)", TopDirName)
      StringLen, SourceAbsolutePathLength, A_LoopReadLine
      SourceAbsolutePathLength--
      Loop, Files, %A_LoopReadLine%*.*, R
      {
         SplitPath, A_LoopFileLongPath, FileNameWithExt, SourceSubDirPath, , FileName
         StringTrimLeft, TargetSubDirPath, SourceSubDirPath, SourceAbsolutePathLength
         FileGetTime, TimeStamp, %A_LoopFileLongPath%
         FileCreateDir, %2%%TopDirName%%TargetSubDirPath%
         FileCreateShortcut, %A_LoopFileLongPath%, %2%%TopDirName%%TargetSubDirPath%\%FileName%.lnk
         FileSetTime, %TimeStamp%, %2%%TopDirName%%TargetSubDirPath%\%FileName%.lnk
      }
      Continue
   }

   SplitPath, A_LoopReadLine, FileNameWithExt, , , FileName
   FileGetTime, TimeStamp, %A_LoopReadLine%
   FileCreateShortcut, %A_LoopReadLine%, %2%%FileName%.lnk
   FileSetTime, %TimeStamp%, %2%%FileName%.lnk
}
Replace %FileName% with %FileNameWithExt% in all four FileSetTime and FileCreateShortcut lines as necessary.

HTH
Roman
Last edited by Hacker on 2016-06-13, 16:44 UTC, edited 1 time in total.
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 »

Worked nicely after making all four replacement at FileSetTime and FileCreateShortcut.

You may like to post the script at http://www.ghisler.ch/wiki/index.php/AutoHotkey

Thanks Roman. It is quite helpful for my work.
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

sorcar,
FileSetTime
Darn, my mistake, thanks for noticing.
You may like to post the script at http://www.ghisler.ch/wiki/index.php/AutoHotke
Done.
Thanks Roman. It is quite helpful for my work.
You are welcome. ;)

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