Explorer selection?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Cat
Posts: 32
Joined: 11 Nov 2011 12:04

Explorer selection?

#1 Post by Cat » 25 Feb 2012 12:31

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?

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Explorer selection?

#2 Post by Squashman » 25 Feb 2012 12:45

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Explorer selection?

#3 Post by foxidrive » 25 Feb 2012 16:31

You can also place the batch file in the SENDTO folder and use right click, send to the batch file.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Explorer selection?

#4 Post by aGerman » 25 Feb 2012 16:42

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

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Explorer selection?

#5 Post by Squashman » 25 Feb 2012 17:07

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.

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Explorer selection?

#6 Post by !k » 26 Feb 2012 10:41


perotto
Posts: 1
Joined: 26 Feb 2012 12:39

Re: Explorer selection?

#7 Post by perotto » 26 Feb 2012 13:55

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?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Explorer selection?

#8 Post by foxidrive » 26 Feb 2012 14:37

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Explorer selection?

#9 Post by foxidrive » 26 Feb 2012 14:41



This seems to work in translating to english.

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

Post Reply