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

4
votes
0answers
34 views

Odd behavior of FindFile

Running FindFile gives some odd results on my machine: FindFile["HTTPClient`"] Result: ...
5
votes
3answers
107 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 ...
2
votes
1answer
118 views

Binary file gymnastics

I have an unformatted binary file generated by fortran 77 and i want to import it in Mathematica. The file is formed by 5 data arrays with double precission float numbers. The problem is that seems ...
1
vote
3answers
202 views

How can I use functions in file paths?

I'm very new to Mathematica and I'm trying to write into a file. I want to have a function in my file path. For Example: ...
0
votes
1answer
39 views

How to output matfiles in Mathematica?

I am new to Mathematica, if there is anything wrong, do not hesitate to tell me? ...
3
votes
1answer
83 views

How to make new line in mathematica file output?

I know that new line is classically made by "\n". I want to make a string with lines of data and then export it into a file: ...
0
votes
1answer
40 views

Is there the possibility to write many times a value in definite list of file1.nb?

The commands testData = RandomReal[{0, 1}, {1, 1}]; Export["C:\\Users\\Alex\\Desktop\\1\\file1.nb", testData]; write the “testData” (value generated by ...
11
votes
1answer
152 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 ...
0
votes
2answers
54 views

What does CreateDirectory[] return?

Based on: CreateDirectory returns the full name of the directory it creates, and $Failed if it cannot create the directory ...
6
votes
2answers
234 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: ...
0
votes
2answers
61 views

Get a filename used in an import and store it as a variable

Hopefully a simple one for you (or at least seemingly)! I import a .txt file, from which i make a ListLinePlot. I simply want to read in the name of the file, store it in a variable so I can use it ...
4
votes
0answers
50 views

How to force the writing of buffers onto disk?

Usually, buffering is good; except when you critically need to write data to disk. Is there a way to force the writing of buffers onto disk? (I'm using a binary file) I believe a ...
8
votes
1answer
205 views

Prevent Export from overwriting files

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

Exporting File Outside Home Directory

When running Mathematica (v10) on my Raspberry Pi, I'd like to output an image file to a directory other than /home/pi. I understand that letting Mathematica write ...
3
votes
2answers
83 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 ...
0
votes
1answer
57 views

Export array data into a file

I tried to solve some equation for different values of parameter t and put results into array. Then I wanted to write this data into a txt-file. So i did it with ...
1
vote
1answer
47 views

Searching if a directory exists within a folder

I hope this question is not a duplicate, but I could not find any other question which answered my specific question, which is: I have the following folder structure (just an example): ...
0
votes
1answer
41 views

How to get only the directories (not the files) inside the current directory? [duplicate]

FileNames["*"] lists all the files and directories inside the current one. How can I list only the directories?
2
votes
1answer
70 views

Code reuse between files in the same directory

At the moment, I am producing various complicated interactive plots. They all share a common "code base", with modifications on top of it. I would like to refactor my code so that the various files ...
1
vote
1answer
43 views

Can i change the default search paths?

When i try to load packages on this computer, i get an error (i already know the packages work). I think the issue might be to do with the fact that mathematica can't process the network drives, some ...
0
votes
0answers
27 views

Can't Load .rst file

I've been working with the FeynRules 2.1 package in Mathematica 10. If I download the MC4BSM_2012 FeynRules files and run the Mathematica Notebook I've got no problem in Ubuntu (A lot of warnings ...
2
votes
2answers
140 views

Adding NotebookDirectory to $Path when notebook opens

I'm trying to get relative notebook paths work without evaluating $Path = Append[$Path, NotebookDirectory[]]; each time I open a notebook. A bonus would be to keep ...
1
vote
1answer
84 views

How to evaluate the same code in a whole bunch of existing notebooks

I have a large folder of existing notebooks, each currently containing a single cell of input. I would like --- in each of these notebooks --- to evaluate that cell, evaluate a new chunk of code I've ...
4
votes
1answer
55 views

how to make SaveAs saves to NotebookDirectory[] instead of NotebookBrowseDirectory[]?

I find Mathematica handling of directories utterly bizarre to say the least. I end up losing changes and seeing files saved in wrong folder due to this. Even in Version 10.01 which I am using, on ...
4
votes
2answers
206 views

How can I import and split lines with ASCII separator?

This is my data file, each line was separated by SOH, maybe hex \x001, I've tried some options of ...
0
votes
2answers
73 views

File Handling. How to save the progress in a file?

Assuming I already have the file created. I have a programme that,returns an output, in our case number. I want Mathematica to save this number in a file, together with results saved from previous ...
1
vote
1answer
114 views

ReadList can't read “.csv” data with correct line number?

Well, the problem was solved today. Since "testAll.csv" is generated by Java/Eclipse, and I noticed that the LineSeperator is ...
2
votes
1answer
36 views

Put/Get don't accept a string-valued expression as filename [duplicate]

I'm trying to do the following with an expression: filename=StringJoin[{"myfile", ToString[someNumber],".m"}]; expression >> filename; But mathematica ...
0
votes
0answers
89 views

How to automatically Import, Name and Export multiple images? [duplicate]

Sorry for the very basic question but I'm really new to Mathematica. I have a directory(myDataDir) full of images (myImage1.tif, myImage2.tif...) I have a piece of code (let's call it ...
1
vote
1answer
126 views

Copy/Pasting code that contains double quotation marks leads to broken code [duplicate]

Sometimes, when copy/pasting code that contains a string (double-quotes around it), the copy of the code fails to evaluate. For example, the original code ...
1
vote
0answers
53 views

SemanticImport::unexpinvaliderr error when using trial version

I am trying to use SemanticImport for a personal experiment. I can correctly import a tsv file from a path, but if I change ...
3
votes
1answer
135 views

How does Mathematica use system environment variables?

Is there a common way in which environment variables are accessed, stored, or used by the kernel? There are built-in functions for querying and setting vars in the system environment, but there are ...
1
vote
2answers
102 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 !
10
votes
0answers
79 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 ...
7
votes
1answer
131 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 ...
0
votes
0answers
40 views

How to get the subdirectory of a ftp weblink?

For example, I can use FileNames["*",dir] to get all subdirectory under dir if dir is some directory of my local computer. Suppose that I want to get all ...
2
votes
1answer
59 views

What's the complete list of file name extensions used by Mathematica?

What's the complete list of file name extensions used by Mathematica? The ones I know are Before V8 .m .nb .mt After V9: ...
1
vote
0answers
40 views

Default starting location of “Save as…” dialog in OS X [duplicate]

In the answer to this previous question, user Szabolcs says On OS X (I'm using 10.9 and Mathematica 9) the file chooser dialogue will remember the last location you used. So if you Save/Open ...
7
votes
2answers
107 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 ...
1
vote
1answer
48 views

How to copy a uncertain name file with the command CopyFile in Mathematica

I have many files named like this "GSM697492_500_D1.CEL", and a another file which contain the first part of the file name like this"GSM697492". I want to copy the some of the CEL files from one ...
4
votes
2answers
87 views

Minimal label to distinguish among a list of directories

I have a list of long directory names. For each directory name, I need a label just long enough to distinguish itself from the rest. Each label should be a ...
4
votes
1answer
146 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. ...
3
votes
1answer
45 views

Where can I permanently modify Directory[]?

First I set SetDirectory["F:\\learning_mma"];Directory[](*ok,success*) and then I quite the kernel: Quit[] an then ...
2
votes
1answer
55 views

What's wrong with this RenameFile?

I want to rename a .txt file. For example create a file on your Desktop and name it use TEST.TXT, now I want to rename it to ...
0
votes
2answers
58 views

Use modified part of file path as new file name

i want to import an image, modify it and then export the modified image. Something like this: img = Import["C:\\Images\\e4271-5.jpg"] Some modifications ...
17
votes
0answers
216 views

A documented syntax of FileNames doesn't work?

bug present as of 10.0.2 According to the documentation for FileNames: However when I attempt to use this syntax I get an error: ...
0
votes
1answer
66 views

Rename a list of files [duplicate]

I need to rename a list of files .bmp having name like 1.bmp, 2.bmp,...,155.bmp. I want to get a list of files having the same number of digits in name like 001.bmp,002.bmp....,155.bmp. I am trying ...
3
votes
1answer
66 views

Windows Insert File Path

Suppose I want to Save["filename", foo] under Windows. Ordinarily, the way to deal with file names under windows is to open the Insert dialogue and find a file path, but in this use case, the file is ...
12
votes
1answer
167 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 ...