|
Answer» Is there any way read a shortcut.lnk file and then copy the file its pointing to, into another directory..??
so SAY like DOC123.lnk exists in folder "C:\Documents and Settings\%username%\RECENT\" and it points to "C:\Documents and Settings\%username%\Desktop\DOC123.RTF" is there anyway to read that shortcut.lnk file then copy the file it points to, into another directory, then delete that shortcut.lnk file..??Code: [Select]@echo off setlocal enabledelayedexpansion
REM easier to decode lnk files in vbs
REM Create vbs in current folder echo set WshShell = WScript.CreateObject("WScript.Shell")>GetLnkTarget.vbs echo set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>GetLnkTarget.vbs echo wscript.Echo Lnk.TargetPath>>GetLnkTarget.vbs
REM set destination folder set destinationfolder=C:\my path\my folder
REM for each lnk file in current folder... for /F "delims=" %%L in ('dir /A-D /b /s *.lnk') do ( REM get lnk file drive letter:\path\name.ext into variable set linkfilename=%%~dpnxL REM call vb script which READS shortcut.lnk file & echoes TARGET filename for /f "delims=" %%T in ('cscript //nologo GetLnkTarget.vbs "!linkfilename!"') do ( REM get target file drive letter:\path\name.ext into variable set linkfiletarget=%%~dpnxT REM copy the file it points to, into another directory REM remove "echo" when you are happy it works echo copy "!linkfiletarget!" "%destinationfolder%" REM delete shortcut.lnk file REM remove "echo" when you are happy it works echo del "!linkfilename!" ) )
|