windows 7 - Batch Drag and drop files and folders -


i'm trying copy multiple files , folders drag , drop selection using solution think should this:

mkdir newdir %%a in ("%*") ( echo %%a ^ >>new.set ) /f "tokens=* delims= " %%b in ('type "new.set"') ( set inset=%%b call :folderchk if "%diratr%"=="d" robocopy "%%b" "newdir" "*.*" "*.*" /b /e && exit /b copy /y %%b newdir )  exit /b  :folderchk /f tokens=* delims= " %%c in ('dir /b %inset%') ( set atr=%~ac set diratr=%atr:~0,1% ) 

i've tried throwing code following examples i'm stuck:

http://ss64.com/nt/syntax-dragdrop.html

drag , drop batch file multiple files?

batch processing of multiple files in multiple folders

handling of special characters drag&drop tricky, doesn't quote them in reliable way.

spaces not complicated, filenames spaces automatically quoted.
there 2 special characters, can produce problems, exclamation mark , ampersand.

names ampersand not automatically quoted, batch can called way

mybatch.bat cat&dog.txt 

this produces 2 problems, first parameters aren't complete.
in %1 , in %* text cat &dog.txt part can't accessed via normal parameters, via cmdcmdline variable.
should expanded via delayed expansion, else exclamation marks , carets can removed filenames.
, when batch ends, should use exit command close cmd-window, else &dog.txt executed , produce error.

so reading filenamelist should like

@echo off setlocal enabledelayedexpansion rem take cmd-line, remove until first parameter set "params=!cmdcmdline:~0,-1!" set "params=!params:*" =!" set count=0  rem split parameters on spaces respect quotes %%n in (!params!) (    echo %%n )  pause rem ** exit important, cmd.ex doesn't try execute commands after ampersands exit 

this described in link refereneced drag , drop batch file multiple files?


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -