ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

DONE: Move files, replace with shortcuts to those files

(1/2) > >>

nkormanik:
Move a number of files (let's suppose pdfs) from Folder A, to Folder B.

Create in Folder A corresponding shortcuts to each moved file, now in Folder B.

Any suggestions?

Assume that Folder B already has lots of files, and the ones you are moving over will get mixed with the rest there -- not a simple matter of moving to an empty folder.

Thanks!

Nicholas Kormanik

4wd:
And how do you handle file collision?

nkormanik:
Rename.  Add suffix, say, 001, etc.

Thanks much for asking.

4wd:
Requires Shortcut.exe from here, put it in C:\Scripts or edit the command file to point to where you've copied it.

MovenShortcut.cmd

Installation:
Copy it somewhere.

Running:
Double-click it.


--- Code: Text ---@if (@CodeSection == @Batch) @then     @echo off    color 1a    setlocal EnableExtensions    setlocal DisableDelayedExpansion        echo Select SOURCE folder    for /F "delims=" %%S in ('CScript //nologo //E:JScript "%~F0"') do (        set srce=%%S    )    if "%srce%"=="" goto :End2    echo Selected folder: "%srce%"        echo Select DESTINATION folder    for /F "delims=" %%D in ('CScript //nologo //E:JScript "%~F0"') do (       set dest=%%D    )    if "%dest%"=="" goto :End2        echo Selected folder: "%dest%"        if "%srce%"=="%dest%" goto :End1        :GetExt    echo.    set /P ext=Please enter extension [eg. jpg] ENTER to exit:     if %ext%=="" goto :End2        for /r "%srce%" %%a in (*.%ext%) do (call :ProcessFile "%%~fa")     :End    set ext=    goto :GetExt        :End1    color 1c    echo **** SOURCE and DESTINATION are the same! ****    :End2    set srce=    set dest=    pause    exit     :ProcessFile    setlocal    if not exist "%dest%\%~nx1" goto :move2    :loop    set /a fileCounter+=1    set "fileName=%~n1__%filecounter%%~x1"    if exist "%dest%\%fileName%" goto :loop    move "%~1" "%dest%\%filename%"rem Full path to Shortcut.exe    C:\Scripts\shortcut.exe /F:"%~dpn1.lnk" /A:C /T:"%dest%\%filename%"    goto :endProcessFile        :move2    move "%~1" "%dest%"rem Full path to Shortcut.exe    C:\Scripts\shortcut.exe /F:"%~dpn1.lnk" /A:C /T:"%dest%\%~nx1"     :endProcessFile    endlocal    goto :eof     endlocal    End of Batch section@end  // JScript section // Creates a dialog box that enables the user to select a folder and display it.var title = "Select a folder", rootFolder = 0x11;var shl = new ActiveXObject("Shell.Application");var folder = shl.BrowseForFolder(0, title, 0, rootFolder);WScript.Stdout.WriteLine(folder ? folder.self.path : "");
File collisions will be renamed: {filename}__{number}.{ext}

So goes the theory.

nkormanik:
Beautifully done.  Works like a charm.  Even between different drives.

Thanks very much, 4wd.  Great job.

Nicholas

Navigation

[0] Message Index

[#] Next page

Go to full version