0

What does "f|" do in this bat command

echo f|xcopy /Y /v "foo.exe" "%TargetFile1%"
ruggb
  • 93
  • 1
  • I recommend to read my long answer on [Why does the command XCOPY in batch file ask for file or folder?](https://stackoverflow.com/a/35829012/3074564) The simple solution would be using in this case the internal command __COPY__ of `cmd.exe` although it is not posted with which value the environment variable `TargetFile1` is defined in the batch file. That would be much better and faster. – Mofi Aug 23 '23 at 16:53
  • It is very inefficient letting `cmd.exe` first search in current directory and next in the directories of local environment variable `PATH` for a file with name `xcopy` with no file extension or with a file extension listed in local environment variable `PATHEXT` for finding hopefully `%SystemRoot%\System32\xcopy.exe` and execute this executable deprecated since Microsoft released Windows Vista for copying a single file from the current working directory to the destination directory if the destination directory exists already. – Mofi Aug 23 '23 at 16:57
  • Thanks mofi - since I was just interested in the "f|" function I did not include the TargetFile1 definition. Sorry for the confusion - and I did read your great Why.... – ruggb Aug 23 '23 at 17:16

1 Answers1

0

f| are not modifiers; f is what echo sends to standard output, and | is a pipe, which redirects the standard output of echo to the standard input of xcopy. What effect this has is unclear and may be none at all; I can't find anything that suggests that xcopy prompts for anything from standard input.

Jeff Zeitlin
  • 9,773
  • 2
  • 21
  • 33
  • thanks Jeff This is what happens if I leave it out -- it won't change the RO attribute of the file it is suppose to overwrite – ruggb Aug 23 '23 at 16:51
  • -- it may not even be overwriting it -- without the echo, just xcopy, it does change it – ruggb Aug 23 '23 at 16:58
  • I guess I don't really need the echo as it adds nothing to the output. I think it was someones suggestion, but I don't understand why now. It has been a while. – ruggb Aug 23 '23 at 17:04