Problem right clicking many files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
OM3
Posts: 32
Joined: 17 Mar 2014 08:43

Problem right clicking many files

#1 Post by OM3 » 10 Aug 2017 07:05

I have some code that I can execute on many files.
The files are all CSV files.

So I can do this: mycode.exe abc.csv xyz.csv pqr.csv

I have a batch file with this code:

Code: Select all

mycode.exe %*


So I put this in my SendTo folder.
I right click many files in some other folder...
And my code works a treat! JUST how I need. :)

PROBLEM: on 2 laptops, when I select multiple files and right click, it ONLY sends JUST one file.
DAMN!

These 2 laptops are cheaper non powerful ones - that's the only difference I can think of!
All are Windows 10 with latest updates.

What am I doing wrong?

Thanks.

pieh-ejdsch
Posts: 240
Joined: 04 Mar 2014 11:14
Location: germany

Re: Problem right clicking many files

#2 Post by pieh-ejdsch » 10 Aug 2017 09:48

Hello OM3,
Your endless list of paramaters can be processed simply one after the other.
Step 1:
Start the command with the first parameter.
Check whether there is a second parameter
If yes - change the position of the parameters with shift and go to step 1
If no - end the batch.

You can get help via call /? and shift /?
Now the question is whether your program one after the other edited or whether your program opens itself twenty times or more?

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

Re: Problem right clicking many files

#3 Post by aGerman » 10 Aug 2017 09:58

There are two things I can think of.

1) Ampersand bug:
If the full name of a file doesn't contain spaces but do contain an apersand then the parameter comes in unquoted and causes an error.

2) String limit:
%* will be expanded to a space-separated string of pathes. Note that every passed file contains the whole path of the file. The limit of a string (and thus, of a command line) in batch is 8191 characters.

Steffen

OM3
Posts: 32
Joined: 17 Mar 2014 08:43

Re: Problem right clicking many files

#4 Post by OM3 » 10 Aug 2017 12:24

thanks for the replies guys
i intentionally left out details

the code that gets executed is something like:

Code: Select all

"d:\folder 1\my folder 2\abc def xyz\more spaces\my code.exe" "d:\folder 1\folder abc def\zy ze\ab23c.csv" "d:\folder 1\folder abc def\zy ze\bbbabc.csv" "d:\folder 1\folder abc def\zy ze\aaabc.csv" "d:\folder 1\folder abc def\zy ze\c.csv" "d:\folder 1\folder abc def\zy ze\ac.csv" "d:\folder 1\folder abc def\zy ze\a.csv"


all i want is DOS to give me this.
And it does!!!!!!!!
it works perfectly - only on 2 laptops it just doesnt work.
i have a pause at the end to see what gets executed.

what gets executed is:

Code: Select all

"d:\folder 1\my folder 2\abc def xyz\more spaces\my code.exe" "d:\folder 1\folder abc def\zy ze\ab23c.csv"


@aGerman i wasnt aware of the & bug. probably is a problem. maybe i'll look into making sure it's not later. for now all OK.

string limit: i think i'll be ok with that. good to know though.

@pieh-ejdsch the problem is getting the string and not the execution. the execution of processing one after another is done by my code.

is there any other way i can get many string names into a dos prompt by selecting and right clicking and using sendto?

thanks

OM3
Posts: 32
Joined: 17 Mar 2014 08:43

Re: Problem right clicking many files

#5 Post by OM3 » 21 Aug 2017 06:38

anyone?
still stuck with this problem
it's so annoying :(

would i use powershell to do similar?
never used before ever. but cant be more than one line of code like the dos version?

thanks

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

Re: Problem right clicking many files

#6 Post by aGerman » 21 Aug 2017 10:38

OM3 wrote:it works perfectly - only on 2 laptops it just doesnt work.

... and the question is why it doesn't work on these two laptops?
So what you can try is prepending an ECHO to the command line and append a PAUSE to your code only to figure out what you even get in %*.

Steffen

OM3
Posts: 32
Joined: 17 Mar 2014 08:43

Re: Problem right clicking many files

#7 Post by OM3 » 21 Aug 2017 16:47

@aGerman, thanks for the reply.
It executes with only one file name.
I can select many files and right click.
I'm not 100% sure, but it either takes the item right clicked or the first in the list and passes through.

I'm forced to execute manually on a DOS prompt.

I'm sure it's a Windows related behaviour.
I just want to figure out a way round.

Any ideas?

Thanks.


Post Reply