|I'm using the following batch file to automatically create an argument for a program from user input and a filename listing using the DIR command.|
Set /P output=Enter filename:
for /f "tokens=* delims= " %%a in ('dir/b/OD *.txt') do (
set /a n+=1
set v=!v! %%a
program.exe %output%.txt %v%
I've had to change the batch since the program has file size restrictions. I found out that the copy /b command does the same with no restrictions.
I've revised the batch, to work with the copy command by adding a "+" in line 5:
set v=!v! %%a +
As the copy command uses "+" to add files, the revised batch file with a "+" added has one extraneous "+" at the end, causing the batch file to fail.
The output ends up as file1 + file2 + file3 +, instead of file1 + file2 + file3.
Is it possible to delete the last "+" within the batch file or redirecting the output to a file then automatically deleting it from that file, then using that file as input for the variable to create the argument.
Or am I going about this the long way?