0

I want to dir a folder and get in a variable all the names of the *.csv files.

Does anyone know how can I do this?

Nidis
  • 165
  • 6
  • 13
  • possible duplicate of [Windows batch files: How to set a variable with the result of a command?](http://stackoverflow.com/questions/889518/windows-batch-files-how-to-set-a-variable-with-the-result-of-a-command) – Helen Jul 07 '11 at 10:08

2 Answers2

3

Using Bash you can try:

dirlist=`ls -1 *.csv`
echo "$dirlist"

Under windows you can read the following Q and A:

Windows batch files: How to set a variable with the result of a command?

Something like:

for /f "delims=" %%a in ('dir') do @set foobar=%%a

Change 'dir' to what you want. I have no windows machine close by, so cannot test.

Community
  • 1
  • 1
zaf
  • 22,776
  • 12
  • 65
  • 95
0

I apologize for a duplicate response, but StackOverflow has reputation counters that impede me from certain actions.

When executing directly on the command-prompt, use the following form:

for /f "delims=" %a in ('whoami') do @set myaccount=%a

The form in previous answer is intended when used in a .bat or .cmd file.

M.Markfort
  • 17
  • 2