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

76
votes
1answer
3k 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 ...
36
votes
3answers
809 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 ...
24
votes
1answer
377 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 ...
19
votes
4answers
801 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 ...
15
votes
1answer
148 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, ...
14
votes
3answers
948 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 ...
14
votes
2answers
175 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 ...
13
votes
2answers
1k views

Relative paths for portable notebooks in Mathematica

I cannot find how to use relative paths in Mathematica. My directory structure is simple. ...
13
votes
5answers
452 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 ...
12
votes
2answers
301 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 ...
11
votes
2answers
506 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 ...
10
votes
3answers
132 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 ...
10
votes
1answer
187 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 ...
9
votes
2answers
299 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 ...
9
votes
2answers
861 views

How to place cdf file in Microsoft Word, Powerpoint or in interactive PDF file?

I would like to create a presentation for my lecture in which I would use Mathematica CDF files. Let's say I want to have such interactive content: ...
8
votes
3answers
386 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 FileNames, StringSplit and GatherBy but in the end I couldn't find even a ...
8
votes
1answer
186 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 ...
7
votes
1answer
175 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 ...
6
votes
4answers
332 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 ...
6
votes
2answers
218 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
2answers
720 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
221 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 ...
6
votes
2answers
322 views

Using NotebookDirectory in batch-mode

I am running Mathematica via the terminal (Linux) and my .m-script contains the command: ...
6
votes
1answer
253 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 ...
5
votes
1answer
96 views

What happened with the file?

What happened with this file? infile = "\\test data.txt"; outstr = OpenWrite[infile]; instr = OpenRead[infile]; Read[instr, Record]; Close[instr]; All ...
5
votes
2answers
158 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 ...
5
votes
2answers
134 views

How to resolve a Unix symlink?

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

Open data file from CDFPlayer?

Using a CDF program running in CDF Player, is it possible to use a system dialog box, or even just an Import statement such as Import["*.CSV"], to import data from a text or comma separated file on a ...
5
votes
1answer
201 views

Mathematica 10 doesn't support path containing Chinese characters

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 front end. I got path like ...
5
votes
2answers
128 views

Reading non-tabular data with NaN-s from file

A NaN stands for an entry that is not a number/undefined/missing/infinite/etc. On my machine the C code printf("%f", 0/0.) produces ...
5
votes
1answer
162 views

How to trash files / directories?

Both DeleteFile and DeleteDirectory can only delete files / directories, and lack the option to move them to the trash. Is ...
5
votes
2answers
261 views

How to remove an expression from a file?

To read in expressions from a file, one can do ReadList[file, Expression, 3]. How to do the opposite, i.e. remove a number of expressions from a file, modifying ...
4
votes
2answers
127 views

Find a notebook I had open recently

I worked on a notebook a few weeks ago and now I can't find after looking through the most likely directories. The recent list only has 6 items in it, none of them the notebook in question. Is there a ...
4
votes
2answers
393 views

Importing array with complex numbers

This is probably an easy question: I am exporting the results from a longer calculation into a dat-File, then I set the cell to non-evaluatable and put an Import in front, so I can later work with the ...
4
votes
2answers
133 views

Equivalent of __FILE__?

Many languages define a special identifier whose value is the path to the source file currently being processed. (For example, in C, this is done through the ...
4
votes
1answer
237 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 ...
4
votes
2answers
105 views

Find file names in directory

I am trying to find the list of any file in any directory of a given name (by in the directory, I mean directly in the directory, so in a directory which is in the directory would not count). For the ...
4
votes
2answers
149 views

Cusom PopupMenu file selector

Lately I come across what I think not uninteresting problem which is a good exercise for the usage of Dynamic. Assume you have files in a directory structure (a ...
4
votes
1answer
344 views

Doubts on scripting: error messages when trying to run and how to process lots of files

I have created my first mathematica 'program' as I think of it, to do some image processing. After reading in an image, it does a lot of stuff (including smoothing, fourier transform, functional ...
4
votes
1answer
144 views

What is the correct way to provide Mathematica with a path to Python user scripts?

What is the correct way to provide Mathematica with a path to Python user scripts? Simply executing Python as a shell command, using something like ...
4
votes
0answers
73 views

Accessing files in different directories [duplicate]

I have a problem that I am trying to work on. My Folder structure is like this. Application(MainDirectory) AppData( Secondary directory where files are Design.m, Layout.m, and Evaluation.m) ...
3
votes
2answers
170 views

How to check which file is older

Is there a command in Mathematica to check the date when a file was last modified? Suppose I have two notebooks: File1.nb and ...
3
votes
3answers
139 views

Properly ordering the output of FileNames for a directory consisting of files with consecutive integer names [duplicate]

Say I have a number of files in a directory at some location (C:\dir1\dir2\dir3...), and I pull an array of strings corresponding to the file names with the command: ...
3
votes
1answer
71 views

Why does Thread FileDate give an error message?

I tried for example Thread[FileDate[FileNames["new*", "h:\\temp\\", 1]]] It gives FileDate::fstr: File specification ...
3
votes
1answer
56 views

Order imported files by their alteration date

Probably a very easy question, but I could not find the answer, so it would be very nice if you can help me: Let us say I have 10 files, all with the extension ...
3
votes
1answer
162 views

Manipulate and FileNameSetter don't want to play nice together

In a Manipulate, one can specific the type of an individual control like so: Manipulate[v, {v, Red, ColorSetter}] I tried to ...
3
votes
1answer
155 views

Windows Explorer Natural Order

Currently there are a list of notebooks in Windows that I am processing in a folder. Ideally I would like the notebooks to be concated in the same order as how they display in Windows Explorer. I ...
3
votes
1answer
71 views

how to write TableForm expression into file?

Now I have a list stored in data as follows data = {{"Ca", 1, 1, 1}, {"Ca", 2, 2, 2}, {"Ca", 3, 3, 3}} the ...
3
votes
2answers
498 views

Importing data into an array, column by column

I'm building a large matrix having different sized rows consisting of a few columns. The different columns are imported .txt files. Why can't I build the matrix column by column? For example, I ...
3
votes
1answer
170 views

Writing results directly to file

I am trying to find all simple paths in a large directed graph (542 vertex, density ~ 5%) between two nodes. For this purpose, I use the algorithm from this thread. Unfortunately, my computer is ...