drag and drop a selection into a .BAT
-
Hi, I'm new to this forum and this is my first post. I want to select a number of files and drag/drop then onto an icon (behind which is a .bat) Then the .bat should process one file after the other. .bats as I understand only accept 10 arguments (old DOS anachronism) but even on under Unix one has this problem and for that purpose the is a technique, called xargs. Is there something like that (freely) available for Windows?
-
Hi, I'm new to this forum and this is my first post. I want to select a number of files and drag/drop then onto an icon (behind which is a .bat) Then the .bat should process one file after the other. .bats as I understand only accept 10 arguments (old DOS anachronism) but even on under Unix one has this problem and for that purpose the is a technique, called xargs. Is there something like that (freely) available for Windows?
Krischu wrote:
.bats as I understand only accept 10 arguments
That's not really true - .BAT files can only refer to the first 10 elements on the command line ( %0 - %9, where %0 is the name of the batch file ). If you know you have more ( or suspect you have more ) you can use the 'SHIFT' command to move the arguments 1 place to the left, that is, %1 becomes %0, %2 becomes %1, and so on and what would have been '%10' is now %9. This sample text will print all of the arguments on the command line.
@ECHO OFF :LOOP ECHO.%1 SHIFT IF "%1" == "" GOTO END GOTO LOOP :END
Place this code in a file called SHFT.BAT and then invoke it with something like: SHFT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Regards, Dan Remember kids, we're trained professionals.
Don't try this at home!