Page 1 of 1

Explorer selection?

Posted: 25 Feb 2012 12:31
by Cat
Is there any way (extensions, etc) to use an explorer selection screen in batch to assign a full file path name to a variable?

Like this:
Image

And when you select a file and click "open" it sets, say, %file% to the full path of the file you selected.

Any way to do this, or should I just use another code language for this?

Re: Explorer selection?

Posted: 25 Feb 2012 12:45
by Squashman
You can drag and drop a file onto a batch file.
The files you drag and drop onto a batch file becomes its command line arguments so you can access them just like you would if you were launching the batch file with a command line from the cmd prompt.

Code: Select all

@echo off
echo This is the path of the file: %~f1
echo This is the file name: %~nx1

Re: Explorer selection?

Posted: 25 Feb 2012 16:31
by foxidrive
You can also place the batch file in the SENDTO folder and use right click, send to the batch file.

Re: Explorer selection?

Posted: 25 Feb 2012 16:42
by aGerman
Cat wrote:Is there any way (extensions, etc) to use an explorer selection screen in batch to assign a full file path name to a variable?

There is no way to show a dialog box using pure batch. There is no "extension" for batch. All you could do is to write your own console tool in another programming language that would write the selected path to stdOut. Could be done with each language that supports WINAPI (GetOpenFileName()) or the Common Item Dialog. Not sure whether you're familiar with those programming languages.

Regards
aGerman

Re: Explorer selection?

Posted: 25 Feb 2012 17:07
by Squashman
foxidrive wrote:You can also place the batch file in the SENDTO folder and use right click, send to the batch file.

Yeah. And since it looks like they are using Vista or 7 the batch file could use the CLIP command to copy the path or file name to the clipboard.

Re: Explorer selection?

Posted: 26 Feb 2012 10:41
by !k

Re: Explorer selection?

Posted: 26 Feb 2012 13:55
by perotto
I've been looking for a way long time, to get in dosbatch the multiple selection from windows explorer. I mean the multiple selection you made on selecting many files in a folder. I want this selection as parameter string and the batch should called only one time. Perhaps there is a specific function to get this multiple selection for further working on?

Re: Explorer selection?

Posted: 26 Feb 2012 14:37
by foxidrive
Perotto,

place this batch file in "c:\Documents and Settings\username\SendTo\Echo filenames.bat"

Then use explorer and select several files and right click, select sendto and then click echo filenames. It will also work for folders.

Code: Select all

@echo off
:loop
if "%~1"=="" (
pause
goto :EOF
)
echo "%~1"
shift
goto :loop

Re: Explorer selection?

Posted: 26 Feb 2012 14:41
by foxidrive


This seems to work in translating to english.

http://translate.google.com.au/translat ... -stroki%2F