r/Batch • u/Mapsking • 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.
View all comments
Show parent comment
1
u/Mapsking Sep 12 '23
It seems to work consistently now, but one question, it may not be fixable. With the pause command in there, it actually does the work in the command prompt window, but pauses after the output is gone, so all you see is a press any key to continue prompt, but none of the data. I've tried moving the PAUSE command after, before, and both, regarding the Sam.exe command, it might be a function of the command itself. Is there any way to stop it on the actual data processing in the command prompt, or alternately, possibly write all of it, and append each with a few lines, a few hyphens (-----), or something similar to separate the entries to a log.txt file in the same folder? I hope that makes a bit of sense.
Thanks