{file} bugged?

Okay in the help it says following: This control sequence inserts the name of the first selected file or folder in the active Lister.

Create a new button, change it to msdos mode, enter following code:

echo {file} pause
Click ok, select two or more files and hit the button!
You will see that it will output all selected files. It seems the code gets executed more then once or whatever. :slight_smile: Would be nice to get that cleared up! Costed me alot of time to find that out :neutral_face:

Hi Littlex,
Even more here:

Try this,
echo {file} > Drive:\Somedir\filename.txt

This will give you a text file of the first selected file.

redirects output.
Hit the button again and a new file is created.

Then try this,
echo {file} >> Drive:\Somedir\filename.txt

This will give you a text file of all selected files line by line . This can be extremely useful.

redirects and appends output.
Hit the button again and it will add even more files.

When you use this control sequence with a Native Dopus function I think only the first file selected is used.

Now try this,
echo {allfilepath} > Drive:\Somedir\filename.txt

This will give you all files selected on one line until Dos Errors due to it's line character limit. Select lots of files.


I think it's more the description that is wrong/misleading than the {file} command itself.

{file} will run the line once for each file selected, instead of running it once with all selected files on the same line.

It's very useful for commands that only work on one file at a time, as well as when the full list of files becomes too long for DOS command-line limits.

I guess it would be good to add a switch to {file} so that it can be told to stop after doing the first file, but the way it works now is by design and useful.

Yea Tsunami thats nice and when you are currently into that do you know how to read the files back into the cmd so you could work with them? :slight_smile:

Nudel, maybe yes but we dont know exactly. I think it would be nice to have an official word on that
me stabs jon :slight_smile:

And btw i still dont know any programm which takes the file param one by one if it has a cmd mode. (Would be pretty stupid imo)

MS DOS syntax:
For %%F in (filename.txt) DO Type %%F

JPSoft Syntax:
For %F in (@%filename.txt) DO (


Is there a way to just read in the firstline? :slight_smile:

Littlex wrote:
Is there a way to just read in the firstline? :slight_smile:[/quote]

In MS DOS I don't know .

In JPSoft ( 4Dos, 4NT, and Take Command ),
Yes, make this batch file.

@echo off
Set I=0
For %F in (@filename.txt) DO (
echo %F
Set I= %@EVAL[ %I + 1]
IF %I == 1 QUIT



Hmm, to bad that there is now way todo that under dos. Searching for a solution which would work on evrey pc.

Danke tsunami :slight_smile:

I'm not sure what your ultimate goal is, but you should be able to do this with a DOpus button and a simple batch file.

The DOpus button:

Name=Echo First Selected
Tooltip=Echoes only the first of the selected files or folders
Func1=cd C:\Mine\cmd
Func2=C:\Mine\cmd\Test.bat {F!}

And "C:\Mine\cmd\Test.bat" is a simple batch file consisting of only the following:

@echo off
echo %1

In DOpus, the Test.bat batch file is run and all the selected files and folders are sent to it as parameters by the DOpus external control code of: {F!}

In the simple batch file, %1 represents the very first selected file or folder sent to it by DOpus. If you wish to strip the quotes from %1 (if it contains them) change %1 to %~1

Of course this just echoes the first selected thing to the console window, you would have to take it from there to do what you want.

Note this should work with CMD, Take Command, and 4NT scripts (and perhaps 4DOS, but I do not use 4DOS so I'm only guessing).


Hi John,

Yes, 4DOS works too.
The syntax difference is extremely minor between the JPSoft products.

Great idea John !
Unfortunately, the problem still isn't solved.

Try selecting several files and then run your button and batch file.
What happens is that it pauses for each file selected !
It runs all selected files one by one . : (

This is what our German friend was pointing out.

I think I'm going to have to attempt to dig into some C++ .
I'll see if I can get an independant command line exe that processes strings.


Strange, those are not the results I get. Are you sure you are using {F!} instead of {file} ?

With {F!} (or %*) only the top DOpus selection is returned via the batch file and that's the way it should work.

However, if I use {file} instead of {F!} then yes, the results are as you suggested.

If Littlex happens to want more than just the first selection he could use %2 for second selection, %3 for the third...and so on up to %9 (that's for CMD scripts, for 4NT it extends to 512).


Thanks John !!!

Yes, you're quite right. I was using {filepath} .
I totally missed it !
It does make some kind logical sense that Not Required {allfilepath} or {F!} result in the first file selected.
Note that Not Required {filepath} or {f!} doesn't work.

We can now answer Littlex's question and mine.
You're batch file is correct !

Thanks again,

Hmm quite nice workarround but its for a dopus button i am planning to release and i dont think most ppl want to place a batch somewhere etc. I am trying to work after the KISS principe (Keep it simpl stupid)

Well again I don't know how you want to use it, but the button below should echo only the first selected "thing" to the console window, pause, then exit. Of course you would have to change ECHO to what you want to do, and the "& pause" will likely need to come out. Just make sure you leave the final "& exit" on the same line with ECHO (or whatever you do with %1) or you will get all the selected files/folders.

Just FYI, this takes advantage of a little known feature of command scripting known as tunneling.


Name=Echo only first selected
Func1=echo %1 & pause & exit

Just a little follow-up. The button below would likely be better suited as it does nothing if nothing is selected. Whereas the previous button I posted would try to echo the first selected thing whether anything is selected or not.


Name=Echo First
Tooltip=Echo only first selected file or folder
Func1=call :process {F}
Func3=echo %1 & pause & exit