Link to home
Start Free TrialLog in
Avatar of ReneGe
ReneGeFlag for Canada

asked on

Batch File: "Drag and Drop" multiple files to batch file

Hi there,

How can I make this batch file work?

I want to drag and drop multiple files to the batch file, then display them.

The display order is not important.

Thanks,
Rene

@ECHO OFF

REM CREATING ARRAY
FOR /L %%A IN (1,1,100) DO (
   IF "%%A" EQU "" GOTO Display
   SET [File.%%A]=%~%%A
)

:Display
REM DISPLAYING ARRAY
FOR /F "tokens=2 delims==" %%A IN ('SET [File.') DO ECHO %%A
PAUSE
EXIT

Open in new window

SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ReneGe

ASKER

Woohoo!!! I now understand SHIFT :)
Thanks oBdA!

I will also award points to Steve for advise and Bill as part of his answer was used and may be an inspiration to oBdA's answer. Thanks guys!

Cheers,
Rene
For me it would take 84 filenames mainly 8.3 but 85 and it says "go away".  Should sufficent I asssume?

Steve
Avatar of oBdA
oBdA

For the sake of completeness: %* works just as well, it's even a bit shorter; just a matter of personal preference:
@echo off
setlocal enabledelayedexpansion
set /a ArgCount = 0
for %%a in (%*) do (
  set /a ArgCount += 1
  set [File.!ArgCount!]=%%~a
)
for /l %%i in (1, 1, %ArgCount%) do (
   echo ![File.%%i]!
)

Open in new window

Avatar of ReneGe

ASKER

More than ennuf! I will be processing not more then 40 files at a time.

Assuming the limmit is due to the string size of the arguments, I made some few tests. I found that the path\file size does affect the quantity of files being pulled out; something between 8043 and 8172.

Cheers,
Rene
Avatar of ReneGe

ASKER

@oBdA: Cool!
Thanks, glad that got solved, I just didn't have time to do the full write up before...

~bp
Avatar of ReneGe

ASKER

Don't worry Bill. Thanks for your contribution :)