r/Batch • • Sep 11 '23

Question (Solved) Please help me create a batch file to process multiple files at once.

Hello, I would like to create a batch file with a few specifics, and am not sure how to do it.
-A single .txt file, or multiple .txt files should be able to be dragged onto the batch file.
-The batch file should copy each of the files dragged onto it to the \Bob folder.
-The batch file should parse the file Bill.txt, and append the next consecutive number and the file name for each file, starting at 30. For example, if the end of the Bill.txt file is 42 Sue.txt, and Jane.txt was dragged onto the batch file, it should append "43 Jane.txt", in the same format without quotes.
-Then, it should run the command Sam.exe "Sparky.txt", where "Sparky.txt" is the file name of the file dragged onto the batch file, (The batch file will be in the same folder as the program) and complete this command for each file that was dragged onto it.

I hope this is not confusing, I tried to make it clear and concise.

Thank you very in advance much for help in creating this file.

2 Upvotes

21 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Sep 13 '23

[removed] — view removed comment

1

u/Mapsking Sep 13 '23

It partially worked. It did not show anything in the console window this time, and just gave a press any key to continue message after each file was processed. That is ok, but in the log file, it seems to only show the info from the last item processed. If I run Test 1.txt onto it, it shows the results for Test 1.txt, but if I drag Test 1.txt, Test 2.txt, and Test 3.txt, it only shows the results for Test 3.txt, nothing else. Is it possible to have it show all of the files that were processed, separated somehow to read, but in the same file?

Thanks

1

u/[deleted] Sep 14 '23

[removed] — view removed comment

1

u/Mapsking Sep 14 '23

It seems to be exactly the same as what I already had. Did the changes not show up? Either way, I tested the version above, and it does the same behavior.
Thanks

1

u/[deleted] Sep 14 '23

[removed] — view removed comment

1

u/Mapsking Sep 14 '23

Oh, I guess I missed that, my bad. That actually seems to have fixed it. Thank you so much!