简体   繁体   中英

Hide filenames in type command batch file

I'm creating a batch file and the final part of the batch is to concatenate the text from multiple csv files into one. The csv that is created is correct, however when I run the command it shows the file names on a separate line. Even with echo off it still shows. When I simply copy and paste the line into a blank txt file and use @echo off and that's it.. it still shows the output.

type lak-print01.csv lak-print02.csv lak-print03.csv lak-print04.csv or-sdc-print.csv tac-print01.csv tac-print02.csv tuk-print01.csv wa-02print01.csv wa-110print01.csv wa-61print01.csv > MasterPrinterList.csv

The output shown in cmd line is as follows. I just want it to perform the type command w/o showing the files.

lak-print02.csv



lak-print03.csv



lak-print04.csv



or-sdc-print.csv



tac-print01.csv



tac-print02.csv



tuk-print01.csv



wa-02print01.csv



wa-110print01.csv



wa-61print01.csv

Any help?

Redirect StdErr to nul by appending 2>nul . ( type outputs filenames into that.) The command you want is this:

type lak-print01.csv lak-print02.csv lak-print03.csv lak-print04.csv or-sdc-print.csv tac-print01.csv tac-print02.csv tuk-print01.csv wa-02print01.csv wa-110print01.csv wa-61print01.csv > MasterPrinterList.csv 2>nul
type lak-print01.csv lak-print02.csv lak-print03.csv lak-print04.csv or-sdc-print.csv tac-print01.csv tac-print02.csv tuk-print01.csv wa-02print01.csv wa-110print01.csv wa-61print01.csv > MasterPrinterList.csv 2>nul

the file names are printed in error stream so all you need is to add 2>nul at the end.

type also accepts wildcards so you can make your line shorter eg

type lak*.csv or*.csv tac*.csv wa*.csv  > MasterPrinterList.csv 2>nul

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM