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.
2
votes
2answers
83 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 ...
5
votes
2answers
55 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 ...
0
votes
2answers
53 views
when using FileDate----The Creation date of a file is not available on Macintosh and Unix?
when I use
FileDate[filename,"Creation"]
it gives messages like
FileDate::nocreationunix: The Creation date of a file is not available
on Macintosh and ...
3
votes
1answer
59 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
...
4
votes
2answers
101 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 ...
2
votes
1answer
79 views
Why is FileNameJoin not working?
I can not figure out why the code below doesn't work?
aaa >> FileNameJoin[{Directory[],"input"}]
error message came out saying
OpenWrite::noopen: ...
6
votes
2answers
122 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. ...
0
votes
1answer
43 views
Configure initial directory
How can I configure the initial directory? By configure, I mean set it so that when Mathematica starts the initial directory is one of my choosing.
By the by, what exactly is the significance of the ...
2
votes
1answer
71 views
File output and race conditions
Is it possible to know when Mathematica is done writing a file? I'm looking to automate something and I'm wanting to have Mathematica put it in a file using Put[], ...
0
votes
1answer
61 views
String to File removing quotation marks
If I print a string to a file it also adds quotation marks to the string. Here is an example:
a = "test \t test"
a >> file
FilePrint["file"]
How can I ...
6
votes
2answers
229 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:
...
3
votes
3answers
94 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:
...
7
votes
1answer
128 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 ...
1
vote
2answers
71 views
Export with different address
Is it possible to use the Export[] command and add another address other than the usual Home directory that is used?
2
votes
0answers
33 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 ...
10
votes
1answer
154 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 ...
4
votes
1answer
121 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
103 views
How to resolve a Unix symlink?
Does Mathematica have any function to resolve a Unix symlink (recursively, if necessary) to its real path?
4
votes
2answers
124 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 ...
1
vote
1answer
78 views
Techniques To AutoReplace Browse
Let's say I have a function of the form.
Test[File_,text_]
What would be the most automated way and flexible way to generate an input cell of the form,
such ...
1
vote
0answers
69 views
ReadList with type Expression unable to read scientific notation? [duplicate]
I have a file that defines an array of numbers like this:
freq["AQs"] = 8.846947803007962E-4
...
I am reading the file with ...
3
votes
2answers
152 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 ...
2
votes
2answers
214 views
Combine multiple notebook files into a pdf/rtf/word/etc file?
It's the end of the semester and I have a prof who wants me to turn in a printout of the nb files ive worked on. I have 33 separate files, and I was wondering if there was any easy way I could combine ...
8
votes
0answers
76 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 ...
6
votes
2answers
175 views
Using NotebookDirectory in batch-mode
I am running Mathematica via the terminal (Linux) and my .m-script contains the command:
...
11
votes
2answers
302 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 ...
4
votes
2answers
104 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 ...
0
votes
1answer
83 views
Pop Up for Setting directory path
I am trying to build certain modules in Mathematica 9. I want it to dynamically ask for the directory path ( like file explorer ) when the code cell is executed.
How can I do that ?
...
3
votes
0answers
198 views
Cannot save file
Hello I have a problem in saving files in Mathematica. I can't save not only notebooks but also figures. When I choose to save the notebook it open a window that says:
Mathematica could not find ...
5
votes
1answer
92 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 ...
4
votes
1answer
272 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 ...
-2
votes
1answer
106 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 ...
12
votes
5answers
288 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 ...
-4
votes
2answers
125 views
4
votes
0answers
68 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)
...
-4
votes
2answers
172 views
How to split a file?
Is there a way to split an external file using Mathematica? (Other than importing it, dividing it internally and exporting the parts)
For instance like some File Split utility do.
17
votes
4answers
534 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 ...
1
vote
1answer
192 views
Renaming files of form FileName(i).csv to NewNamej(k).csv where j increments and k resets to 1 when there is a jump in i?
Edit up top: The accepted answer works splendidly except I had to add //ToExpression to the end of the definition of ns given by ...
7
votes
3answers
328 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 ...
0
votes
0answers
109 views
Do Import and Get work asynchronously? Can I prevent this?
I'm getting strange behavior in some of my notebooks that makes it seem like Import and Get load asynchronously. When I evaluate ...
4
votes
1answer
169 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 ...
1
vote
0answers
251 views
How to set default save directory for notebooks?
Based on certain previous questions, I figured that if my NotebookBrowseDirectory looked like this
...
6
votes
4answers
278 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 ...
2
votes
1answer
152 views
Restrict SystemDialogInput to open certain file types
The documentation for SystemDialogInput shows how to restrict the types of files shown.
SystemDialogInput["FileOpen",".nb"]
...
3
votes
1answer
122 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 ...
6
votes
2answers
163 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 ...
0
votes
1answer
243 views
4
votes
1answer
267 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 ...
0
votes
1answer
215 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 ...
-2
votes
2answers
465 views
How to write output in TraditionalForm into external text files?
I'd like to write output in TraditionalForm into external text files ofile.txt. I tried to use
...