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

87
votes
1answer
4k 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 ...
11
votes
1answer
263 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 ...
18
votes
3answers
1k 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 ...
37
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 ...
21
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 ...
15
votes
3answers
2k views

Relative paths for portable notebooks in Mathematica

I cannot find how to use relative paths in Mathematica. My directory structure is simple. ...
9
votes
1answer
460 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 ...
25
votes
1answer
412 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 ...
5
votes
1answer
356 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 ...
5
votes
1answer
589 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 ...
2
votes
1answer
884 views

How to set default save directory for notebooks?

Based on certain previous questions, I figured that if my NotebookBrowseDirectory looked like this ...
14
votes
5answers
695 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 ...
15
votes
1answer
209 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, ...
12
votes
2answers
843 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 ...
7
votes
4answers
443 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 ...
13
votes
2answers
326 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 ...
12
votes
1answer
201 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
3answers
178 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 ...
5
votes
1answer
175 views

Watch File in Directory .NET

How might I watch for a specific file to change in a directory using Mathematica/.NET code? The following works in .NET but fires twice when you change the file. ...
2
votes
1answer
67 views

How can I automatically name files being exported based on input parameters

I have Mathematica notebook that performs some operation say a=2 b=3 c=5 d=4 how do I set the output file after evaluation to be named using the values ...
13
votes
3answers
493 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 ...
19
votes
0answers
325 views

A documented syntax of FileNames doesn't work?

Documentation discrepancy present through 10.2 According to the documentation for FileNames under Details: However when I attempt to use this syntax I get an ...
3
votes
2answers
90 views

Most efficient way of splitting a file into length-prefixed blocks

Let's say I have a really big file (>100MB) that consists of length-prefixed blocks, i.e. the first byte of each byte block indicates the length of the rest of the block. This is a simplified example ...
8
votes
1answer
88 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
4answers
148 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 ...
6
votes
5answers
162 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: ...
4
votes
1answer
196 views

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

I have several hundreds of .csv files that are not logically named (contains numbers, characters, and special characters), all stored in a directory. Each file has large but unequal number of rows and ...
2
votes
2answers
263 views

Fastest way to concatenate many text files in a given directory

I have about 1 million .txt text files in a directory which I would like to all concatenate in one single text file (separated by a newline character "\n"). Because of the number of files and their ...
6
votes
2answers
336 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
1answer
329 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 ...
4
votes
1answer
173 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
187 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 ...
2
votes
0answers
37 views

Using a variable in Get [duplicate]

This question is different from the answer here Infix form of PutAppend ( >>> ) does not work with variable becasue it is dealing with folders and not filenames. I have a file path which I ...
1
vote
2answers
119 views

Change Temporary Directory

How to change the value of $TemporaryDirectory ? I need to change it because there is not enough space on the C drive and the calculation seems to stop after a while !
1
vote
3answers
3k views

How to write values of function to file?

For example, say I wanted to plot Sin(x) like this: Plot[Sin[x],{x,0,2 Pi}] But instead of plotting to a graph, I want to now tabulate the values of Sin[x] to a ...
0
votes
1answer
57 views
0
votes
1answer
433 views

StringJoin/FileNameJoin doesn't quite work in script

My mathematica script is as follows: ...
0
votes
1answer
312 views

SetDirectory - predefined directory possible? [duplicate]

Possible Duplicate: Relative paths for portable notebooks in Mathematica I have a deep subdirectory structure, and the calculations should always be done in one of the deepest ...
-1
votes
1answer
130 views

How can I check which file is modified in specific directory?

I want to find which files are recently modified in a specific directory. For this purpose, I wrote a function named Test. The function's argument is ...