Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I stumbled on question 217394 which explains how to copy files sorted alphabetically into one single file. Trying to implement the command myself rendered the following error message: The system cannot find the file specified.
The command I am trying to run is here:

for /f %i in ('dir /a-d /o-n /b O:\OrdersExport\Order*.txt') do @type %i >> C:\Users\Admin\Documents\OrderImport.txt

The error does not appear if I browsed to the folder in question first:

C:\>cd OrdersImport

I simply want one line to copy from destination to that single file.

By the way, if it matters, O: is a mapped folder over network

share|improve this question

The dir command list the filenames only. So %i variable is filled with relative paths. If the command is not run from the directory in question use %~fi to expand the relative path to absolute path.

for /f "tokens=*" %i in ('dir /a-d /o-n /b "O:\OrdersExport\Order*.txt"') do (
    @type "%~fi" >> "C:\Users\Admin\Documents\OrderImport.txt"
  • tokens=* deals with spaces in filenames, so %i is always whole line of the dir output.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .