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

1
vote
3answers
61 views

How to make a list (of data points) whose name is the same as the file name from which the data is imported [duplicate]

I have a set of files, e.g. file1.dat, file2.dat,... containing data (list of data points to plot, manipulate...) I want to do the following ...
1
vote
1answer
34 views

Select folder with ChoiceDialog and return deepest folder name

For selecting a folder which contains data files I use the following code: ChoiceDialog[{FileNameSetter[Dynamic[dir], "Directory"], Dynamic[dir]}]; ...
0
votes
1answer
69 views

How to zip a folder? [duplicate]

This straightforward approach doesn't seem to work: In[42]:= cmd = StringSplit@"zip -r ~/data.zip ~/test/*" In[43]:= RunProcess@cmd Related: How can I ...
4
votes
1answer
83 views

depository/repository of Mathematica notebooks

Is there a depository/repository of Mathematica notebooks (not necessarily Mathematica packages) where one can upload some of their notebooks so as others can access them easily?
1
vote
2answers
71 views

How to set the relative directory so that they work both in script and in notebook and portable?

Maybe the question is not clear, here I try to state it in more detail: I have a folder named project, for instance. In it I have two folders, one is named ...
4
votes
3answers
136 views

How do I copy files to the clipboard?

Is there a way to mimic the Ctrl + V for a given file? I've got Mathematica to locate a certain file path, but I don't bother to copy the file in File Explorer (I will do this many times).
1
vote
2answers
65 views

How do I set Mathematica to open a specific folder - When I type “Command + O” in OS X [closed]

When I type "Command + O", in Mac OSX 10, Mathematica automatically opens my directory: "Users/john" How can I change this setting to make it open "Users/john/Documents/Mathematica/GameOfLife" the ...
1
vote
1answer
53 views

How to export a list of numerical data to a file in the terminal?

I have a very simple program that export a list to a data file in table form. ...
6
votes
1answer
59 views

How do I directly read the Nth byte from a binary file?

I have a very large binary file (several hundred GB) which I would like to process using Mathematica. I only need to process a few bytes of this file at a time, and I know in advance which bytes I ...
2
votes
1answer
49 views

Get (<<) Evaluate File Name

This seems like a simple question due to lack of experience, but I can't seem to find an answer through searching. I am trying to read back a symbol from a ...
2
votes
1answer
50 views

Where is ExampleData stored on my system

When I enter: Import["ExampleData/numberdata.csv"] Where does Mathematica go on my system to find the file numberdata.csv? Or, what Mathematica command will ...
2
votes
2answers
75 views

How to separate the double columns while reading file

I have a file which has contents of the form 10533 "MENDOZAT " 115.0000 : 1 1.00000 Now I want to separate the words and get it as a list. like ...
4
votes
0answers
31 views

Can't get Mathematica to Import PDF files with diacritics on the file name

Tested with versions 9.0.0, 10.0.2 and 10.3.0, all under OS X 10.10.5. The drag-and-drop ...
1
vote
1answer
44 views

Moving files around

In order to introduce some order into the chaos, I want to move all pdf files on some big directory, say, "U:\", into a library directory, say: "U:\Library". So I get a list all files situated ...
1
vote
0answers
36 views

How to test if Import was successful? [duplicate]

I am importing and processing a bunch of files. Sometimes, for whatever reason, some of these files are not successfully imported so I'm looking for a way to Abort ...
12
votes
1answer
130 views

Path Names Longer Then 256 on Windows

Is there a way to work with pathnames that are longer then the typical 256 in Mathematica? For example run the following in Cygwin ...
8
votes
2answers
338 views

Case Sensitive File Names Windows(POSIX)

Is there an undocumented way to work with case sensitive files in Windows(If not is this a bug - it doesn't appear to match OSX or Linux behavior)? First enable case sensitivity in Windows. Then ...
1
vote
1answer
83 views

Using ReadList to import specific arrays of a multi-dimensional variable

Consider a large numerical variable (almost 1GB) which was constructed like below: output={scalar1,{Matrix1,Matrix2,Matrix3,scalar2}}; I used ...
3
votes
1answer
99 views

SetDirectory has problems when path is long and contains too many “_” [closed]

The following example code does not work (error: "Cannot set current directory ..."). I am running Mathematica 10.2.0.0 on Windows 10. ...
2
votes
1answer
86 views

Set permission of created directories by CreateDirectory

What determines permission mask of directories created by CreateDirectory? Calling CreateDirectory["/tmp/dir"] gives ...
2
votes
1answer
183 views

Relative Path in Mathematica

I am aware of this question: Relative paths for portable notebooks in Mathematica In the answer it is said that Directory[NotebookDirectory[]] is the ...
2
votes
1answer
38 views

Import variable assignments from external files into different contexts

(I use Mathematica 9.0.1 on OS X 10.10.5.) I have two text files. One is named file1.txt with the contents ...
1
vote
0answers
32 views

Problem of FileEncoding of the output file of FileTemplateApply

Problem of FileTemplateApply FileTemplateApply will change a file-encoding[UTF8] into a file-encoding[WindowsANSI], it seems it doen't accept CharacterEncoding ...
5
votes
2answers
102 views

How to load a file in a directory inside the current working directory

How can I use something like that NotebookEvaluate[ "Mathematica\\SomeFile.nb"]; Instead of ...
7
votes
5answers
196 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: ...
3
votes
1answer
168 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 ...
2
votes
1answer
43 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 ...
8
votes
1answer
116 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
32 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
273 views

How to return notebook's own file name

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

Mathematica Save Directory [closed]

Mathematica saves everything to Documents. I want it to save it into a folder Documents/Mathematica.
3
votes
1answer
79 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 ...
1
vote
2answers
58 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
76 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
58 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 ...
0
votes
1answer
74 views

How to 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 ...
0
votes
0answers
80 views

Setting UserBaseDirectory for custom packages

Is there any reason to set $UserBaseDirectory to be anything other than the default? On my mac its set as ...
1
vote
0answers
99 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 ...
4
votes
0answers
45 views

Odd behavior of FindFile

Running FindFile gives some odd results on my machine: FindFile["HTTPClient`"] Result: ...
10
votes
4answers
261 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
182 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
229 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
43 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
357 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
2answers
111 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 ...
14
votes
1answer
236 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
81 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
259 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
127 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 ...