0

I wish to have a batch file in my SendTo menu (win7). I want to right click a bunch of files and send them to this batch file which will then concatenate their file names into one long string with a + sign between, like so

filepath1+filepath2+filepath3....

Something like this is getting close but I don't know how to separate each parameter

for %%i in (%*) do echo %* > names.txt
tyee
  • 317
  • 1
  • 3
  • 14
  • You don't need the loop because $* is all the files so `echo %* > names.txt` should be all you need. Otherwise look at https://stackoverflow.com/a/39049747/2193968 – Jerry Jeremiah May 23 '17 at 03:11
  • But that would put each file on it's own line, yes. I need filenames concatenated. Just found my answer. – tyee May 23 '17 at 03:22
  • It doesn't put them all on one line if you don't use the for loop. – Jerry Jeremiah May 23 '17 at 03:46

1 Answers1

0
@echo off
setlocal enabledelayedexpansion
FOR %%A IN (%*) DO (
set VAR=!VAR!+%%A
)
echo %VAR:~1% > v:\1\names.txt
tyee
  • 317
  • 1
  • 3
  • 14
  • Thank you for this code snippet, which may provide some immediate help. A proper explanation [would greatly improve](//meta.stackexchange.com/q/114762) its educational value by showing *why* this is a good solution to the problem, and would make it more useful to future readers with similar, but not identical, questions. Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight May 23 '17 at 12:37