42 votes
Accepted

Argument completions for user-defined functions

There is an undocumented file in the installation directory named specialArgFunctions.tr: ...
user avatar
  • 67k
27 votes

Argument completions for user-defined functions

Before you start using this, be aware that this is all undocumented and unsupported functionality. It may change at any time, it may crash Mathematica, and it may bite you when you least expect it. I ...
user avatar
  • 224k
23 votes
Accepted

How to get the directory of a package?

FindFile will tell you which file will be loaded when you ask for a particular package with the backtick syntax. DirectoryName ...
user avatar
  • 224k
20 votes
Accepted

Path Names Longer Than 256 on Windows

With a few rare exceptions, Mathematica is generally unable to work with long path names on Windows. This response presents two strategies to work around this difficulty: extended-length path syntax ...
user avatar
  • 67k
20 votes

What is the difference between a .wl package and a .m package?

As after half a year there is still no answer, here are some very short answers from my comments: the difference is just the file ending as far as I know. if you have installed MATLAB (or another ...
user avatar
18 votes

How to export data to a plain text file?

dat = Table[{i, Sin[i], Cos[i], Tan[i]}, {i, 4}] // N; Export["test.txt", dat, "Table", "FieldSeparators" -> " "] FilePrint["test.txt"] 0....
user avatar
18 votes
Accepted

What kind of check does DirectoryQ exactly perform?

Since Mathematica is written in the C programming language, it is likely that any file-system status operation is doing nothing more than calling C's built-in functions. In this case, that would be <...
user avatar
  • 1,496
17 votes
Accepted

How to check whether the folder is created, and if not, create it?

...
user avatar
  • 224k
17 votes

How to check whether a .txt file is empty

FileByteCount will give 0 for empty text files and is very fast (0.00003 seconds per file on my machine). ...
user avatar
  • 12.6k
16 votes

Can Mathematica edit large binary files in-place?

We can do it straightforward in Java using JLink: ...
user avatar
  • 6,268
15 votes
Accepted

Prevent Export from overwriting files

Your basic requirement is met with: ...
user avatar
  • 264k
15 votes
Accepted

Relative Path in Mathematica

If you want to have the parent directory of the current directory, use ParentDirectory[]. The parent directory of your notebook can be found using: ...
user avatar
15 votes

Better random (unique) file name

It might be best to use CreateUUID. CreateUUID[] "73ccc27c-687f-4eca-8214-ceeb8a8b7773" ...
user avatar
  • 32.5k
13 votes
Accepted

$Path hijacked by PacletManager?

Edit From version 9 PacletInfo.m file requires "Kernel" extension with Context ...
user avatar
  • 14.7k
13 votes
Accepted

How to return notebook's own file name

You have to add a few extra commands to NotebookFileName to remove the directory. Last@FileNameSplit@NotebookFileName[] Hope ...
user avatar
  • 39.2k
13 votes
Accepted

Making a Dataset that emulates `ls -tlra`?

Build your own Here I create a Dataset of files, taking advantage of the "Rules" option for ...
user avatar
  • 28.4k
12 votes
Accepted

Searching a phrase in all *.nb files

Here is a way to search from within mathematica: ...
user avatar
  • 38.3k
12 votes

Making a Dataset that emulates `ls -tlra`?

Try something like that ...
user avatar
  • 7,075
12 votes

Implementing a Better Grep Command

Mathematica allows text searching using regular expressions (based on the PCRE library). It would take some work to re-implement the whole grep functionality within ...
user avatar
12 votes

Wrong function of NotebookDirectory[] in the 12.1 version

This is a certainly a bug. The fix for it is going to be available in the next release (version 12.1.1). In the meantime, perhaps the following workaround code may help ...
user avatar
  • 25.1k
12 votes
Accepted

How to determine the file type of a .m file?

It's somewhat of a meme that WL has a top-level function for everything, but it's kinda true: ...
user avatar
  • 17.8k
11 votes
Accepted

Mathematica 10 doesn't support path containing Chinese characters

In Mathematica 10.0.0 for Windows, I have experienced similar problems. When non-ASCII characters were placed after \ in a string, they were decoded in a strange way. (Character '\' is used as a path ...
user avatar
  • 1,066
11 votes

How to return notebook's own file name

No need to go through all the machinations of trimming/applying a cascade of functions, simply: CurrentValue["NotebookFileName"]
11 votes

How can I get a FileNameSetter-like dialog inside my own custom dialog?

Not perfect but a good start. Openers expand/collapse trees but it does not affect the preview pane. Clicking on the directory name does. ...
user avatar
  • 132k
10 votes
Accepted

Get the last line from each of a large number of files, transform them, and write all results to a single new file

A simple way to read the last line of a file uses ReadList to get all lines from the file and then returns the last element of the list: ...
user avatar
  • 67k
10 votes

Argument completions for user-defined functions

This can be accomplished with the AddCodeCompletion function in the function repository. Evaluate the following piece of code: ...
user avatar
  • 68.7k
10 votes
Accepted

Find file names in directory

All three of parameters for FileNames can affect the depth at which Mathematica searches for results. It seems like your confusion is a result of interaction among ...
user avatar
  • 8,342
10 votes

Error when implementing StartProcess[] in loops (Do, While, Table)

The problem is that the stdin stream for each process is being left open and needs to be closed. To demonstrate the issue, we create a single process: ...
user avatar
  • 67k
10 votes
Accepted

why CopyFile cannot overwrite existing file?

Use the OverwriteTarget -> True option. Alas, this is not specified in the documentation. ?? CopyFile gives, among other ...
user avatar
  • 8,342
10 votes
Accepted

how to get the size of a directory(total size of all files under this directory or its subdir or ...)

There is also a function in the Internal` context (for now) that does that ...
user avatar
  • 25.1k

Only top scored, non community-wiki answers of a minimum length are eligible