Inside Man
Inside Man

Reputation: 4297

Making A List Of Images in a folder

I need to send some images to a program at once, it will accept them with the format below:

"1.jpg" "2.jpg" "3.jpg" ...

The spaces between filenames with quotes is necessary, I mean this will be wrong: "1.jpg""2.jpg", space is required.

Now I want to declare an variable named list which stores names of all images in a folder. for example List="1.jpg" "2.jpg" "3.jpg"

How to do that?

Upvotes: 1

Views: 64

Answers (1)

MDEV
MDEV

Reputation: 10838

This should do what you're after:

@echo off
setlocal enabledelayedexpansion
set arglist=
for %%i in (*.txt) DO set arglist=!arglist! "%%i"
echo file.exe %arglist:~1% ::This is just for testing
ENDLOCAL
pause

The %arglist:~1% is just ignoring the first character because it's an unwanted space from the concatenation process

Upvotes: 1

Related Questions