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

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: ...
0
votes
0answers
116 views

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

I have a directory (myDataDir) full of images ("myImage1.tif", "myImage2.tif", ...), and I ...
3
votes
2answers
1k views

How to change working directory for calculation and save

I'm having a problem setting the working directory. I want to do some computation and save my data at one location (D), but in the code below you can see that mathematica shifts automatically to a ...
3
votes
1answer
154 views

Get the creation time of a file

Windows is able to tell me when (date & time) a file in the file system was created or altered. Is it possible to get such information in Mathematica, e.g., get the creation time of a text file ...
1
vote
2answers
252 views

Processing all files in a folder automatically

I have a lot of files in a folder that needs to be process through a function that I have written in Mathematica. I need help writing a code that would process all the files automatically. ...
2
votes
1answer
37 views

How to use MakeExpression in terminal?

This is in continuation to the question in Infix form of PutAppend ( >>> ) does not work with variable. I was trying to use ...
11
votes
1answer
105 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 ...
0
votes
2answers
66 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 ...
0
votes
1answer
98 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 ...
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 ...
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. ...
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 ...
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, ...
0
votes
0answers
31 views

How to attach raw data to a mathematica file? [duplicate]

I have to send my Master's Thesis to the professor and I don't know how I can send him the mathematica file and the raw data files so that he doesn't have to change all the paths for the importing. ...
9
votes
2answers
258 views

How to return notebook's own file name

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

Analogue of NotebookDirectory[] for scripts (to get the directory path of my script.m)?

Is there a way to get the script directory from inside a Mathematica script? I want a function analogue to NotebookDirectory[] (which doesn't work for scripts). Is ...
0
votes
1answer
42 views

Mathematica Save Directory [closed]

Mathematica saves everything to Documents. I want it to save it into a folder Documents/Mathematica.
1
vote
2answers
51 views

Deleting a line from a file

I'm writing a Mathematica script that writes output to a file every 10min as backup. However, I'd like it to overwrite the previous content so as not to use to much storage. Is there a function for ...
2
votes
1answer
48 views

SetDirectory[NotebookDirectory[]] in one notebook causes Directory[] to change in a different notebook

This is causing me lots of problems. I found that issuing SetDirectory[NotebookDirectory[]]; in notebook A.nb causes subsequent ...
4
votes
1answer
52 views

How to define a function to save a list to a same-name file

I want a convenient way to save lots of intermediate data lists into files, so that next time the files can be imported automatically to homonym list variables in the notebook, without having to ...
2
votes
1answer
153 views

Writing/exporting files outside the Raspberry Pi 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 ...
0
votes
1answer
74 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?
0
votes
1answer
60 views

How fix backup command?

The following old code, from "Dr Bob" and Selwyn Hollis with a minor modification by me, produces a palette that allows one to create successive backups to the input notebook. But the code breaks in ...
1
vote
0answers
75 views

Privilege Violation

I am working with a file that is about 400Mb. The intent is to read in the information, transform the data and output to a new file. Before writing to a new file, the directory is checked for an ...
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 ...
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. ...
6
votes
2answers
240 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: ...
2
votes
1answer
147 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
218 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: ...
4
votes
0answers
40 views

Odd behavior of FindFile

Running FindFile gives some odd results on my machine: FindFile["HTTPClient`"] Result: ...
8
votes
1answer
234 views

Prevent Export from overwriting files

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

How to output matfiles in Mathematica?

I am new to Mathematica, if there is anything wrong, do not hesitate to tell me? ...
4
votes
1answer
168 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: ...
1
vote
3answers
2k views

How to export data to a plain text file?

I am preparing data used by a command line program. It requires data in a simpliest possible format: value_x1 value_y1 value_x2 value_y2 ... value_xN value_yN ...
13
votes
1answer
182 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 ...
5
votes
1answer
65 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 ...
0
votes
2answers
73 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 ...
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 ...
0
votes
2answers
79 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
58 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 ...
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 ...
1
vote
1answer
52 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): ...
1
vote
1answer
57 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 ...
2
votes
1answer
79 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 ...
0
votes
0answers
32 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 ...
7
votes
2answers
120 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 ...
2
votes
2answers
155 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
85 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 ...
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 ...