# copyfiles

> copy some files

Latest version **2.4.1** (published 2020-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install copyfiles
pnpm add copyfiles
yarn add copyfiles
bun add copyfiles
```

Provides the commands `copyup`, `copyfiles`.

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.4.1 |
| Published | 2020-11-27 |
| First published | 2014-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/copyfiles) |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 22.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 421 |
| Maintainers | cwmma |

## Links

- npm: https://www.npmjs.com/package/copyfiles
- Repository: https://github.com/calvinmetcalf/copyfiles
- Homepage: https://github.com/calvinmetcalf/copyfiles#readme
- Issues: https://github.com/calvinmetcalf/copyfiles/issues
- npm.io page: https://npm.io/package/copyfiles

## Dependencies (7)

- [glob](https://npm.io/package/glob.md) ^7.0.5
- [noms](https://npm.io/package/noms.md) 0.0.0
- [yargs](https://npm.io/package/yargs.md) ^16.1.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4
- [through2](https://npm.io/package/through2.md) ^2.0.1
- [minimatch](https://npm.io/package/minimatch.md) ^3.0.3
- [untildify](https://npm.io/package/untildify.md) ^4.0.0

## Recent versions

- 2.4.1 (latest) — 2020-11-27
- 2.4.0 — 2020-10-01
- 2.3.0 — 2020-05-27
- 2.2.0 — 2020-01-17
- 2.1.1 — 2019-07-09
- 2.1.0 — 2018-09-04
- 2.0.0 — 2018-03-06
- 1.2.0 — 2017-02-02
- 1.1.1 — 2017-02-02
- 1.1.0 — 2017-01-25
- 1.0.0 — 2016-06-21
- 0.2.2 — 2016-06-21
- 0.2.1 — 2015-04-27
- 0.2.0 — 2015-04-22
- 0.1.2 — 2015-04-22
- … 3 more at https://npm.io/package/copyfiles/versions

## README

copyfiles [![Build Status](https://travis-ci.org/calvinmetcalf/copyfiles.svg)](https://travis-ci.org/calvinmetcalf/copyfiles)
===

copy files easily

### Install

```bash
npm install copyfiles -g
```
### Command Line

```bash
  Usage: copyfiles [options] inFile [more files ...] outDirectory

  Options:
    -u, --up       slice a path off the bottom of the paths               [number]
    -a, --all      include files & directories begining with a dot (.)   [boolean]
    -f, --flat     flatten the output                                    [boolean]
    -e, --exclude  pattern or glob to exclude (may be passed multiple times)
    -E, --error    throw error if nothing is copied                      [boolean]
    -V, --verbose  print more information to console                     [boolean]
    -s, --soft     do not overwrite destination files if they exist      [boolean]
    -F, --follow   follow symbolink links                                [boolean]
    -v, --version  Show version number                                   [boolean]
    -h, --help     Show help                                             [boolean]
```

copy some files, give it a bunch of arguments, (which can include globs), the last one
is the out directory (which it will create if necessary).  Note: on windows globs must be **double quoted**, everybody else can quote however they please.

```bash
copyfiles foo foobar foo/bar/*.js out
```

you now have a directory called out, with the files foo and foobar in it, it also has a directory named foo with a directory named
bar in it that has all the files from foo/bar that match the glob.

If all the files are in a folder that you don't want in the path out path, ex:

```bash
copyfiles something/*.js out
```

which would put all the js files in `out/something`, you can use the `--up` (or `-u`) option

```bash
copyfiles -u 1 something/*.js out
```

which would put all the js files in `out`

you can also just do -f which will flatten all the output into one directory, so with files ./foo/a.txt and ./foo/bar/b.txt

```bash
copyfiles -f ./foo/*.txt ./foo/bar/*.txt out
```

will put a.txt and b.txt into out

if your terminal doesn't support globstars then you can quote them

```bash
copyfiles -f ./foo/**/*.txt out
```

does not work by default on a mac

but

```bash
copyfiles -f "./foo/**/*.txt" out
```

does.

You could quote globstars as a part of input:
```bash
copyfiles some.json "./some_folder/*.json" ./dist/ && echo 'JSON files copied.'
```

You can use the -e option to exclude some files from the pattern, so to exclude all all files ending in .test.js you could do

```bash
copyfiles -e "**/*.test.js" -f ./foo/**/*.js out
```

Other options include

- `-a` or `--all` which includes files that start with a dot.
- `-s` or `--soft` to soft copy, which will not overwrite existing files.
- `-F` or `--follow` which follows symbolinks

## copyup

also creates a `copyup` command which is identical to `copyfiles` but `-up` defaults to 1

### Programic API

```js
var copyfiles = require('copyfiles');

copyfiles([paths], opt, callback);
```
takes an array of paths, last one is the destination path, also takes an optional argument which the -u option if a number, otherwise if it's `true` it's the flat option or if it is an object it is a hash of the various options (the long version e.g. up, all, flat, exclude, error, verbose, follow, and soft)  

### Tilde support for home directory
when the src/dest path start with tilde for home directory under windows, please make sure -u or -f is added in options or use copyup command. if not you will get `Error: Illegal characters in path.`

---
_Source: https://npm.io/package/copyfiles · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
