windowsbatch-filedirectoryshortcutlnk

Copy files from folder of lnk files back into folder


I have a bunch of folders, each containing a number of shortcut link files to mp3 files existing in completely separate folders. eg:

/rock-mp3-shortcuts
/jazz-mp3-shortcuts
/funk-mp3-shortcuts

what command would I run (or program to use) to copy all the underlying mp3 files back into the folders of shortcuts that are pointing to them.

I basically want to get all the files in each genre folder of shortcuts to then copy into my portable mp3 player.


Solution

  • You can check shortcutJS.bat with which you can create or check info about .lnk.You will need it in the same directory with this code:

    @echo off
    
    setlocal
    ::set your location on the line bellow
    set "mp3_dir=c:\mp3_dir"
    pushd "%mp3_dir%"
    for /r %%# in (*.lnk) do (
    
        for /f "tokens=1* delims=: " %%a in ('shortcutJS.bat -examine "%%~f#"^|find /i "target"') do (
            echo location of %%# : %%~fb
            rem !!!!  remove the echo on the line bellow if everything is ok !!!!
            echo copy "%%~fb" "%%~dp#"
        )
    
    )
    endlocal