Skip to main content
32 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 ...
Szabolcs's user avatar
  • 235k
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 ...
Albert Retey's user avatar
  • 23.6k
18 votes

What secrets are hidden away in your init.m and where do you place it? Please help me build the ideal init.m

I am an init.m ascetic. And I doubt after 30+ years of using Mathematica I will change. Everyone else, who wishes to, may proclaim how it is indispensable to their workflow, and I will accept their ...
17 votes
Accepted

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

...
Szabolcs's user avatar
  • 235k
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). ...
Carl Lange's user avatar
  • 13.1k
16 votes

Can Mathematica edit large binary files in-place?

We can do it straightforward in Java using JLink: ...
BlacKow's user avatar
  • 6,438
15 votes

Better random (unique) file name

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

Searching a phrase in all *.nb files

Here is a way to search from within mathematica: ...
george2079's user avatar
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 ...
rhermans's user avatar
  • 36.7k
12 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: ...
C. E.'s user avatar
  • 70.7k
12 votes

Making a Dataset that emulates `ls -tlra`?

Try something like that ...
swish's user avatar
  • 7,921
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 ...
Alexey Popkov's 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 ...
ilian's user avatar
  • 25.5k
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: ...
Sjoerd Smit's user avatar
  • 23.6k
11 votes
Accepted

Is there a predecessor to the new command CreateFile?

The new function CreateFile has two main tasks, CreateFile[] - will create a file in the "default area for temporary files on ...
Jason B.'s user avatar
  • 68.7k
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. ...
Kuba's user avatar
  • 137k
11 votes
Accepted

Obtain short path on Windows

Windows Command Line Here is a way using the Windows command line: getShortPathName[path_] := Import["!for %p in (\""~~path~~"\") do @echo %~sp", "Text"] So ...
WReach's user avatar
  • 68.9k
11 votes

What secrets are hidden away in your init.m and where do you place it? Please help me build the ideal init.m

I tend to put a lot of little functions in my init.m file, functions that take arguments and use module variables. I found that I would now have Global symbols like ...
10 votes

Can I get a list of more than fifteen of the most recent notebooks opened?

As commented by J. M. you can persistently increase the menu size with: SetOptions[$FrontEnd, "NotebooksMenuHistoryLength" -> 20] (* 20 is arbitrary *) You ...
10 votes
Accepted

What's the fastest way to read a simple numerical list?

Your real problem is I have a large .txt file In a txt file, each number is represented by a sequence of bytes with possibly varying length followed by a ...
halirutan's user avatar
  • 113k
10 votes

Opening Mathematica file in Google drive

If you have a public link, you can follow the answer to this question, and basically just import the data Import[url, "Data"] If you need to authenticate to get ...
rhermans's user avatar
  • 36.7k
10 votes
Accepted

Renaming Files with Mathematica

The following method does not require a specific fixed number of digits in the start of file name and does not depend on specific fixed non-numeric separator such as "-". ...
Vitaliy Kaurov's user avatar
10 votes
Accepted

How to zip folders

This can be achieved with Map (/@). 1) Identify the folders you want to compress: ...
ktm's user avatar
  • 4,242
9 votes
Accepted

How to make a better `Sort` in my case

How about this one?: SortBy[#, FileBaseName] &@fileNames
sunt05's user avatar
  • 4,367
9 votes

Get n filenames in a directory?

Using OS shells commands seems to be much faster, although their output will need some massaging to obtain only the file names. For instance, the following works quite well on my system (Win7-64): <...
MarcoB's user avatar
  • 67.3k
9 votes

Opening Mathematica file in Google drive

There is now a Chrome app for opening Wolfram notebooks in Wolfram Cloud. Once you've installed the app, you can visit your Google Drive on the web and double-click to open a notebook file. You'll ...
John Fultz's user avatar
  • 12.6k
9 votes
Accepted

Find image dimensions without importing the full image?

The documentation says how to do this. Import["image.jpg", "ImageSize"] // AbsoluteTiming {0.052691, {2048, 1366}}
C. E.'s user avatar
  • 70.7k
9 votes
Accepted

How to follow symbolic links on disk?

AbsoluteFileName will resolve symbolic links. Example on my machine: ...
Szabolcs's user avatar
  • 235k
9 votes

Most efficient way to read data from file in Mathematica

You may also check the ReadList function. For example considering following input (having an implicit structure of String, Number, String, Number): ...
vindobona's user avatar
  • 4,381
8 votes
Accepted

Cannot find BaseDirectory or UserBaseDirectory in Mac OS El Capitan

Ok, so the quick way to find given directory is just to use SystemOpen @ dir. E.g. SystemOpen @ $UserBaseDirectory I go ...
Kuba's user avatar
  • 137k

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