Title: Archive without root folder in .zip [node-archiver]
Tags: javascript;node.js;archive;node-archiver
Question: I'm using node-archiver to archive folder "export" with photos inside.

Everything works ok but inside archive I got folder 'offers' and photos are in this folder.

I would like to have like a "flat" .zip, so when I'll unpack my .zip it unpack photos without that 'offers' folder.

My code:

```  const folderPath = '/export/.';
  const output = fs.createWriteStream('test/offers.zip');
  const archive = archiver('zip');
  archive.pipe(output);
  archive.directory(folderPath, false);
  archive.finalize();
```

What I'm getting after unpacking:



What I would like to get:



How can I achieve this?

Regards,
Gemmi

Comment: Hi @Seblor, thx. I already tried that and with `*` node-archiver won't zipping my files.

Comment: Thank you for replay @Shilly It doesn't work in any provided examples :/

Comment: Have you tried `archive.directory( 'export/' , false);` or `archive.glob( 'export/*.*' );` ?

Comment: I think that's because `/export/.` is the same as `/export` so it targets the folder, not the files inside. Try changing the path to `/export/*`

Comment: Oh right, I forgot it should be `.glob` not `.directory`, my bad. Good catch Shilly


Here is another answer: All you need is set prefix via options property. 
Like this

```archive.directory(folderPath, false, { prefix: 'your destination folder' });
```

Regards,
Lukas


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 5, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:03/14/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><node.js><archive><node-archiver>', 'Title': 'Archive without root folder in .zip [node-archiver]', 'ViewCount': 1251, 'id': 55167424, 'user_AboutMe': "<p><strong>By day</strong>: Creating a web and mobile applications with Meteor 1.3 platform.\n<strong>By night</strong>: I'm working on my own project.</p>\n", 'user_AccountId': 4918578.0, 'user_DisplayName': 'Gemmi', 'user_Reputation': 1242.0, 'user_Views': 68.0, 'user_id': 3961826.0}}