-2

My goal is to create a program on a webpage. The program will Fetch an assembly folder. Then extract CNC files from the assembly folder and put the CNC files into one folder and sort the CNC files into 3 other folders (plywood, aluminum, or steel) based upon the filament type metadata in the CNC files.

  • What is the best method to doing this using JavaScript?

  • Is there a way to detect file properties such as whether a file is a CNC using JavaScript?

  • I was also thinking of incorporating Python, since JavaScript is too simple a language for this type of process. Is there a way to link JavaScript and Python, such that JavaScript will be the main class and Python will be used as a subclass(es)?

Thank you!

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
Tahfimul
  • 9
  • 4
  • 1
    Why did you tag this stack-overflow? You can't run python on the users browser. Javascript isn't a simple language, but dealing with files is generally limited in browsers. Your best bet would be to make it something other than a website. – Maya Jul 04 '17 at 15:38
  • @NieDzejkob what can be done other than a website? – Tahfimul Jul 04 '17 at 15:39
  • It depends on what you want to do. Maybe a python script? Maybe a desktop app? Maybe just do your processing on the server? – Maya Jul 04 '17 at 15:40
  • @NieDzejkob Can I just do it using JavaScript? – Tahfimul Jul 04 '17 at 15:41
  • yes, but not in the browser. – Maya Jul 04 '17 at 15:42
  • @NieDzejkob how is a browser limited to dealing with files? – Tahfimul Jul 04 '17 at 15:43
  • you can read files and folders, but the user has to point you to a given file or folder. When you write files, you can only create new files in a specific folder (usually Downloads) – Maya Jul 04 '17 at 15:44
  • @NieDzejkob okay. If I create a desktop application, can I do it using JavaScript solely? If so, can you point me to some sort of framework or code that can get me started? An example desktop application may be? Thank you – Tahfimul Jul 04 '17 at 15:48
  • do you actually need a web page? it sounds like you just want a simple Python script that fetches files and then puts them into your folders. – plsnoban Jul 04 '17 at 16:05
  • @plsnoban I am more comfortable with working on a web page. But it seems that webpages are limited to file processing. But I also want to use JavaScript as much as possible. However, if Python has an easier method for his process, I will want to use that as well. – Tahfimul Jul 04 '17 at 16:07

1 Answers1

0

In, short you can't. It is not possible to do this using JavaScript in the browser. It is entirely possible to do this using Node.js. You can also certainly call Python from JavaScript and vice versa in Node. So to answer your questions:

  • The best method is using Node.js if you want to use JavaScript.
  • It depends on what you mean by "file properties". If you mean the EXIF data, then you can use a package called exif-parser or something similar. Maybe you want the MIME type of the file, if so then use mime-types. There's bound to be a package that you can utilize to achieve your needs.
  • It is possible to run JavaScript from Python and vice versa, but why? Both languages are more than capable on their own.
Cisco
  • 20,972
  • 5
  • 38
  • 60
  • What I mean by file properties are its filament metadata. So the program should be able to detect whether files are CNC. If so, sort them by material, another filament metadata. Are there any packages for this? I don't know what to search for. – Tahfimul Jul 04 '17 at 16:01
  • Is it possible to do this using a desktop application that I will create using node.js? – Tahfimul Jul 04 '17 at 16:02
  • I've never worked with CNC files so I wouldn't know off hand. But as we can see from [this](http://www.modulecounts.com/) chart, npm has thousands of modules/packages. There is bound to be one that suits your needs. If not, then you can most certainly create one and publish it to help others. Yes it's possible to create a desktop application using Node.js with [Electron](https://electron.atom.io/) – Cisco Jul 04 '17 at 16:11
  • Is there a way to know what type of property I am using? Because I don't want to have to look through thousands of packages. Thank you! – Tahfimul Jul 04 '17 at 16:15
  • If I wanted to create a package / module for npm how would I do it? – Tahfimul Jul 04 '17 at 17:35
  • I don't know anything of the CNC file format so i can't really help you there or anything related to CNC in general. You don't have to search through all of the packages since the majority of packages have keywords defined to make searching easier/faster. See this guide for publishing packages: https://docs.npmjs.com/getting-started/publishing-npm-packages – Cisco Jul 04 '17 at 18:06