Resulting in only the LAST file of that first directory being in the log I'm not trying to shoot at you. I just see that you're missing a minor point here, which makes a big difference in what the OP wants. Heck, without your initial post, I wouldn't have been able to figure out how to solve the OP's issue. You gave me what was needed to complete it. Florian Reischl. Thanks for all the input. You must be logged in to reply to this topic.
Login to reply. June 12, at pm Leave the first "-o" alone. Old DOS warrior trick. June 13, at am June 13, at pm Okay, here's some code to demonstrate what I'm talking about. This demonstrates the point the OP was making. June 14, at am I am trying to run a batch file which runs an executable and redirects its output to a log file. The log file must have the date and time as the file name. This is the command I am using:. This command works when pasted directly in cmd.
However, it does not work when pasted in a batch file, and then run in cmd. Cmd interprets the command as follow:. Notice how the file name is truncated and the time is now appended to the command arguments instead of being in the file name. So obviously the command fails.
This is surely something very simple but I have not found any way to fix this. Any help is greatly appreciated. Your problem is, that the timestring may contain a space before 10 o'clock You can replace it with a zero , but I recommend a solution independent of locale settings :. Perhaps the simplest solution for you be this one :. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 6 years, 6 months ago. Active 10 months ago. Viewed 29k times. Thank you! I'm not sure there's a way of using a batch file to pipe backwards, as it's app. Just saying. Thanks for pointing it out. You could probably gin up a PowerShell script using Get-Date - then pipe it into your file, but you'd have to define where it pipes to within the file.
TheRobinsonLovatt: The app. I am open to the idea of having a batch file open the log file and modify its contents; although I'm not sure how helpful that would be. Neither of these are going to help in this case though since he needs to interleave dates and times with the standard output of app. I didn't sum up what you said.
I explained why batch can't do it, and offered some ideas that would do it, and gave some batch code that actually works. You're suggesting to redirect nothing into an environment variable which doesn't make sense. Sorry i din't know i had to specify every little bit. Good to know, i am trying this with a bat file to run an exe but output to a log to capture errors.
Thanks for the link, we have a Dev team that passed the. Todd Thanks for providing this useful info on this page, comes in handy when logging batch scripts. Made it easy to Google.
0コメント