1

Not sure about unix, but in windows you can add attributes to files, like a location on a photo file or a duration on a video file.

Is there a way to do this in node js. Would be very handy with my currently project. It would save me having to create separate attribute data files.

Gordon Truslove
  • 724
  • 2
  • 10
  • 19
  • 1
    You're confusing file attributes, which are part of the the filesystem structure with metadata which may or may be present in part of the file format or some types of files. – hippietrail Mar 27 '21 at 09:34

4 Answers4

2

You may use the WinAttr package to do that.

sGambolati
  • 783
  • 8
  • 25
  • 1
    I guess that would work, but windows only it seems. Pretty sure a lot of cloud systems are on some kind of unix these days. Thanks for the suggestion through. – Gordon Truslove Mar 13 '17 at 16:07
2

See this module:

But it's for attributes like archive, hidden, readonly, system.

I don't think you can add an attribute of of duration to the video file - the duration is written in the container/codec of the video itself. The location for images is in the EXIF data - which can be manipulated with other modules on npm - see:

For the location on a photo file or a duration on a video file you need to use whatever information is appropriate for that given image or video format.

rsp
  • 107,747
  • 29
  • 201
  • 177
  • 1
    I guess that would work, but windows only it seems. Pretty sure a lot of cloud systems are on some kind of unix these days. Thanks for the suggestion through. Location and duration were just examples. – Gordon Truslove Mar 13 '17 at 16:08
1

You can run a SHELL command:

var execSync = require('child_process').execSync;

// Remove Hidden and system attributes:
execSync("attrib -h -s " + yourFolder);

// Add Hidden attribute:
execSync("attrib +h " + yourFolder);
riofly
  • 1,694
  • 3
  • 19
  • 40
0

fs-xattr works like a charm for linux:

Check it out here: https://www.npmjs.com/package/fs-xattr

BruceJo
  • 591
  • 6
  • 17