Questions on obtaining files and directory structure/information and manipulating the said structure/information, searching/renaming particular files in a directory, etc., in an OS independent manner.

learn more… | top users | synonyms

97
votes
1answer
5k views

File-backed lists/variables for handling large data

Background Currently I am working with some large data (most of it generated by Mathematica itself). I usually find it a hassle to do this. For example, I just exported a large amount of data to ...
39
votes
3answers
1k views

How can I set up a versioning system within a notebook?

Since the Frontend crashes a lot, for important work it would be nice to have the notebook automatically branch and save itself every so many minutes. For instance, commands like StartSavingCopies[5]...
29
votes
1answer
554 views

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

In Mathematica 10.x, one now has both .wl Wolfram Language Packages and .m Wolfram Mathematica Packages. What's the ...
26
votes
1answer
436 views

Tool to locate bloat in a notebook?

In developing a notebook, I often find I have created a very boated file that takes a long time to save. I would like to slim it down. It is usually the result of graphics and images, but they may be ...
25
votes
2answers
6k views

How to import all files of a folder at once?

I know how to import one textfile by calling its name filestring = Import["myfile.tex", "Text"]; Then "filestring" is a string with the myfile content. How do ...
23
votes
4answers
1k views

ReadList problem related to Record type

A simple file reading issue is baffling me here. I am reading a around 200 MB textual file in .dat format. Now the file contains many lines but to phrase my problem ...
23
votes
0answers
436 views

A documented syntax of FileNames doesn't work?

Documentation discrepancy present through 10.3 According to the documentation for FileNames under Details: However when I attempt to use this syntax I get an ...
21
votes
1answer
299 views

File-name completion for custom functions

Mathematica 10 has introduces file name completion. It works only with certain built-in functions such as Import, SetDirectory, ...
20
votes
3answers
3k views

Relative paths for portable notebooks in Mathematica

I cannot find how to use relative paths in Mathematica. My directory structure is simple. ...
19
votes
3answers
2k views

List all the directories under the current one

I feel like I am forgetting something obvious, and will remember or be ashamed as soon as an answer turns up. However, I cannot for the life of me get all of the directories in the current working ...
18
votes
2answers
244 views

How to find the package file that stores a certain symbol?

Is it possible to figure out in what file a certain packaged symbol lives in (assuming there is no shadowing between multiple identical symbol names)? I would like to have a function that if, given a ...
16
votes
2answers
1k views

DumpSave for the forgetful

A few weeks ago I created a big matrix, and in order not to have to recreate it, I stored it using DumpSave["file.mx", variable]. Now I want to read it back in and ...
15
votes
1answer
320 views

How to get the directory of a package?

I have a package that I have placed in the $BaseDirectory\Applications directory so that Needs can find it. I have a logo in ...
14
votes
3answers
543 views

Visualizing directories

How do I plot the content of a directory and all its subdirectories into infinity using TreeForm? I've tried using a mix of ...
14
votes
5answers
936 views

Using ReadList and Skip to read a file with periodic alternation of useful and useless data

I am trying a read a file that's arranged such that there's alternating set of rows containing data that I don't need and data that I need. So for my case the first n lines in the files are useless to ...
13
votes
2answers
348 views

Mathematica “prelude”

Is there any way to have the functions from a mathematica file be loaded on startup? For example, in this excellent answer, Jens helps me out and gives me some functions for creating legends for ...
13
votes
3answers
219 views

What kind of check does DirectoryQ exactly perform?

I'm using Mathematica 9.0.1 on Windows XP and my drive letters are assigned as follows: C: and D: are hard local disks, while <...
13
votes
1answer
240 views

$Path hijacked by PacletManager?

Summary: Since Mathematica version 6, the PacletManager seems to have engineered an escalating hijack of the $Path variable. Add-on packages need to have a ...
12
votes
1answer
149 views

Path Names Longer Then 256 on Windows

Is there a way to work with pathnames that are longer then the typical 256 in Mathematica? For example run the following in Cygwin ...
11
votes
1answer
298 views

Infix form of PutAppend ( >>> ) does not work with variable

I'm new to Mathematica, so I suspect this question involves either a misunderstanding involving variables or the usage of >>>. On a webMathematica page (...
11
votes
1answer
111 views

Is there a way to stop Export if the file size is too big?

I've got code that's exporting a file, but the file might be so big that it will take up too much space on the cluster I'm using and crash other users' processes. Is there anything like ...
10
votes
2answers
415 views

How to search a file in a particular system using Mathematica

I want to know if there is any function which can search a file from the whole system and gives the whole path for that particular file. I have tried $Path but it ...
10
votes
4answers
294 views

Handy / flexible directory tree operations

Is there any shorter / more handy / more flexible way to get directory tree as a nested Rules/Associations list? I tried to incorporate ...
9
votes
2answers
286 views

How to return notebook's own file name

What command within a notebook will return the file name of that notebook?
9
votes
1answer
584 views

Mathematica 10 doesn't support path containing Chinese characters

Bug introduced in 10.0 and fixed in 10.0.2 I tried to import file in Mathematica 10 ( windows 7 system), the path contains some chinese characters. After holding ctrl+shift, and drag the file into ...
9
votes
1answer
150 views

How to test if file exists on the front end machine?

When using a remote Mathematica kernel, how can you test if a file exists on the local front end machine? Of course FileExistsQ cannot be used in this scenario, ...
8
votes
1answer
399 views

Prevent Export from overwriting files

Export["filepath1",Expression1] works for me, but if filepath1 already exists, it will be overwritten. I'd like ...
8
votes
1answer
313 views

why CopyFile cannot overwrite existing file?

CopyFile return $Failed when the file exists on destination. is there any way to force CopyFile to overwrite the existing one? the way I use now is DeleteFile and ...
8
votes
1answer
271 views

Drag & drop path info into front end?

On OSX at least, it's possible to quickly retrieve a folder/file path by dragging & dropping the folder/file into the terminal, eg: Is it possible to program Mathematica's front end enable ...
8
votes
2answers
869 views

Using NotebookDirectory in batch-mode

I am running Mathematica via the terminal (Linux) and my .m-script contains the command: ...
8
votes
2answers
495 views

Case Sensitive File Names Windows(POSIX)

Is there an undocumented way to work with case sensitive files in Windows(If not is this a bug - it doesn't appear to match OSX or Linux behavior)? First enable case sensitivity in Windows. Then ...
7
votes
4answers
512 views

How to batch rename a directory of files?

I have a directory of files with the pattern: "some_number.some_name.pdf" I want to remove the "some_number." part from all the ...
7
votes
4answers
197 views

Searching a phrase in all *.nb files

I have so many *.nb files in a folder. In one of them I have written a phrase, unfortunately I cannot remember that file. I am searching about it and the file in ...
7
votes
1answer
338 views

Name of current Notebook

I've searched the documentation, this forum and with google, but I was not able to find how to ask Mathematica to give back the name of the current notebook file one is working on. Perhaps something ...
7
votes
2answers
166 views

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

I'm using Mathematica to control another program (Surface Evolver) through the terminal (ie using StartProcess[]; and ...
7
votes
5answers
204 views

Nested list from a flat folder list

I have a list of folders and files in my current working directory as a result of a built-in function FileNames: FileNames["*", "", Infinity]]. It looks like this: ...
7
votes
2answers
217 views

How does the speed of WriteString compare to other languages?

I'm doing something where the most sensible approach seems to be to open a file and write to it as I process data from some large tables. Old school. While testing the program, I remembered the low ...
7
votes
2answers
406 views

How do I Export through a standard system file save dialog activated by a Button?

As near as I can tell, Export cannot be configured through arguments or options, to present a standard system file save dialog to the user, so that he can specify a ...
7
votes
1answer
426 views

Execute code when file is modified

I have a function the takes some time to complete. The function imports data from a .csv, parses it, and plots certain vectors from there. The .csv is constantly being updated from an external ...
6
votes
2answers
467 views

Using Read for calling external command does not release file handle

The standard and robust method for piping to/from external commands under Windows is to create a temporary file, save the input into it, pipe it to the command and save its output to a second file. ...
6
votes
3answers
292 views

How to make a better `Sort` in my case

I have some file names like this: ...
6
votes
2answers
1k views

How can I open an Excel file and modify it in Mathematica?

I wanted to ask how can I view an Excel file from a Mathematica notebook and modify it. I have seen a similar question, Open Excel file with Mathematica, but the answer involves .NET. Is there any ...
6
votes
2answers
283 views

Why does the hash of a file differ from the hash of its content?

FileHash doesn't allow arguments like FileHash[file,{"CRC32","MD5"}]; A solution could be: ...
6
votes
2answers
188 views

How to resolve a Unix symlink?

Does Mathematica have any function to resolve a Unix symlink (recursively, if necessary) to its real path?
6
votes
1answer
400 views

How to save data using FileNameSetter or similar

I would like to export data to a file using a SaveAs type dialog, using something like FileNameSetter[name,"Save"] to give a browse button. Any help with this ...
6
votes
1answer
88 views

How to make captions for a movie?

I'm trying to make my own video parody with custom subtitles. Creating your own custom subtitles file in a text editor with the SubRip or .SRT format is easy to do, it looks like this: Where 00:...
6
votes
0answers
103 views

How to unlock a stylesheet which is not needed anymore by the FrontEnd

Reply from WRI Support: [...] This indeed seems to be an issue with the Frontend on Windows and I have alerted the development team about this. Unfortunately I do not have a work around at ...
6
votes
1answer
84 views

How do I directly read the Nth byte from a binary file?

I have a very large binary file (several hundred GB) which I would like to process using Mathematica. I only need to process a few bytes of this file at a time, and I know in advance which bytes I ...
6
votes
0answers
76 views

Can't get Mathematica to Import PDF files with diacritics on the file name

Tested with versions 9.0.0, 10.0.2 and 10.3.0, all under OS X 10.10.5. and Linux The drag-...
5
votes
2answers
125 views

How to load a file in a directory inside the current working directory

How can I use something like that NotebookEvaluate[ "Mathematica\\SomeFile.nb"]; Instead of ...