forfiles

forfiles without cmd /c

烈酒焚心 提交于 2019-11-27 09:06:42
I can run a forfiles command with cmd /c , as expected C:\>forfiles /c "cmd /c ping /a" IP address must be specified. However if I remove the cmd /c , it no longer recognizes any arguments, only the base command C:\>forfiles /c "ping /a" Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name Must I use cmd /c , even with external commands on the PATH? This is the original answer. Please read below the line for a complete analysis of the problem and a better way to solve it

forfiles without cmd /c

放肆的年华 提交于 2019-11-27 04:01:05
问题 I can run a forfiles command with cmd /c , as expected C:\>forfiles /c "cmd /c ping /a" IP address must be specified. However if I remove the cmd /c , it no longer recognizes any arguments, only the base command C:\>forfiles /c "ping /a" Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name Must I use cmd /c , even with external commands on the PATH? 回答1: This is the

How do I write a Windows batch script to copy the newest file from a directory?

偶尔善良 提交于 2019-11-26 19:41:30
I need to copy the newest file in a directory to a new location. So far I've found resources on the forfiles command, a date-related question here, and another related question . I'm just having a bit of trouble putting the pieces together! How do I copy the newest file in that directory to a new place? Windows shell, one liner: FOR /F %%I IN ('DIR *.* /B /O:-D') DO COPY %%I <<NewDir>> & EXIT The accepted answer gives an example of using the newest file in a command and then exiting. If you need to do this in a bat file with other complex operations you can use the following to store the file

How do I write a Windows batch script to copy the newest file from a directory?

喜夏-厌秋 提交于 2019-11-26 08:55:22
问题 I need to copy the newest file in a directory to a new location. So far I\'ve found resources on the forfiles command, a date-related question here, and another related question. I\'m just having a bit of trouble putting the pieces together! How do I copy the newest file in that directory to a new place? 回答1: Windows shell, one liner: FOR /F %%I IN ('DIR *.* /B /O:-D') DO COPY %%I <<NewDir>> & EXIT 回答2: The accepted answer gives an example of using the newest file in a command and then