Questions tagged [files-and-directories]
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.
494
questions
1
vote
1
answer
36
views
How to change the appearance of file object?
Sometimes the file path is too long, and it's really inconvenient to open the file by clicking the ">>" button on the right.
Is it able to modify the appearance of file object by ...
0
votes
0
answers
19
views
Temporary directories left behind by the CreateArchive function
The CreateArchive function sometimes leaves empty subdirectories of the form m_x in the destination directory, where x is a ten-digit alphanumeric identifier that ...
0
votes
0
answers
16
views
Issues with Exporting a table cell [duplicate]
I can't seem to export my datasets properly.
The code below shows:
...
4
votes
1
answer
112
views
Is there an easy way to batch the change of StyleSheet in 120 notebooks
At one point in the past I believed that a style sheet colocated with a notebook would not require a path. For example, if my notebook resided in the same directory as this style sheet, the style ...
0
votes
1
answer
62
views
Why do I get a wrong data structure using Module? [closed]
I am using Module and reading rawlen.txt files from nb100, nb200 , ... folders. I have written a piece of program to calculate strain and I expect the results to have the following structure:
{{0.}, {...
0
votes
0
answers
42
views
Could you help me understand where in my code I produce a list with a specific dimension?
I am reading force.txt files from series of folders nb100, nb200 ,nb300, ... . and I need to save the related results as result100, result200, ... in the related directories.
In order to do that I ...
1
vote
0
answers
59
views
Save the mathematica notebook on cloud as PDF on System/Cloud
I am using mathematica on the free Wolfram cloud version.
I first tried using the option of "Print to PDF" available under the "File" on the top of Nav Bar. However, it redirects ...
2
votes
1
answer
84
views
How to copy/merge one directory into another like done by default in windows file explorer?
What is the easiest way to copy one directory into another programmatically?
I tried:
...
1
vote
1
answer
66
views
Compressing a file's name string
I was working with files where each name records a lot of information about what is in its respective file and wanted to compress it a little bit. So I wanted to change it's 'base'.
And I noticed that ...
8
votes
2
answers
229
views
Are there any functions to change file permissions?
I looked but couldn't find any functions that would let me manipulate file permissions from Wolfram Language. I'm talking about things like read-only (on Windows), writable (on Unix), executable (...
0
votes
0
answers
34
views
OpenWrite Error: "already open as"
Mathematica gives the error "[file] already open as [file]" when I execute OpenWrite, even if I use a completely new name and pointer. Could this be related to using both Write and ...
2
votes
0
answers
37
views
Weird behaviour of Image`ImportExportDump`ImageReadPNG
Here is the problematic code,
...
0
votes
1
answer
43
views
Searching directory over a network
I have a network drive mapped on my Windows machine. I need to read data from the network that is nested in a few directories below the root. Example is "G:/Data/folder01/data/date_name/values....
0
votes
0
answers
50
views
Automating the process of restarting mathematica (and all open notebooks) after the operating system updates
The hassle of restarting Mathematica by hand after a required operating system restart makes it tempting to repeatedly delay operating system updates, which is a security risk.
Has anyone written ...
6
votes
5
answers
1k
views
How to sort filenames in actual numerical order?
I have inherited a collection of files that are numbered... something like:
file-0, file-1, file-2, ... file-9, file-10, file-11, ... file-19, file-20, ...
When I Import them, they come in scrambled ...
1
vote
1
answer
78
views
$Path changes randomly from day to day
I use the following code to open my custom code notebook code.m:
NotebookOpen[$Path[[6]] <> "\\code.m"]
But the ...
3
votes
0
answers
141
views
How to get satellite image directly from Mathematica?
First, I get the image of the bands of the desired area from the site https://earthexplorer.usgs.gov/, then I import the images into Mathmatica by addressing them as below:
Select dataset directory:
<...
0
votes
0
answers
78
views
Delete last line in an open OutputStream
I have Mathematica code that creates a file (more precisely, I use OpenWrite and create an OutputStream object) and I use ...
1
vote
0
answers
75
views
Problems writing file on Mathematica: how to bypass this
I am in the quest of writing on a file (original question: How to create a file in a directory and write in it?) doing this:
...
2
votes
1
answer
237
views
How to create a file in a directory and write in it?
I can't find proper documentation on this but basically I want to
open a .txt file to write in Mathematica in a defined path.
then I want to write to that file line by line probably
close the file
...
2
votes
1
answer
155
views
Problems with 'DumpSave' and 'Save' in Mathematica 13.1 on Windows 11
My Mathematica 13.1 crashes when I try to see the result of 'Save' for some very long expressions, and produces short DumpSave files which when clicked on contain only Null.
I have a system
...
1
vote
1
answer
97
views
Load package from notebook directory [closed]
How to import a file in the same directory as the current notebook?
I have tried
Get@FileNameJoin@{NotebookDirectory[], "myPackage.wl"}
but get Get::...
3
votes
2
answers
174
views
How can I list the names of all modules in a long .wl file?
I have a .wl file with lots of utility modules, for example
...
1
vote
0
answers
65
views
How do I import an image from the Windows file system in Mathematica Online?
I have an image file named forest.jpg in the C:\Temp directory. I am running Windows Pro 11
Here's what I tried in a new notebook in Wolfram Mathematica Online
image = Import["C:\Temp\forest.jpg&...
0
votes
1
answer
56
views
How to export file in For loop? [closed]
I am using the following code to export a file with three columns. I am using the Export file command like this but not getting the output. Can someone please help with this?
...
0
votes
1
answer
87
views
Open a Notebook in the same folder, just with SetDirectory[NotebookDirectory[]]
I am a little confused because I belief that the behaviour of SetDirectory was different before. The intention is to be able to open notebooks in the same folder only by specifying the file name, ...
2
votes
2
answers
105
views
How to leave only the filenames beginning with some phrase?
Consider some directory testfolder located in the directory with the notebook. It contains the following files .dat:
...
4
votes
1
answer
82
views
Efficient primorial memoization?
Thinking on this recent question asking to create an primorial list, led me to think
How could we exploit something similar to memoization for primorial?
Maybe something that stored only the largest ...
0
votes
0
answers
74
views
Can you dynamically create variable names in Mathematica? [duplicate]
I was wondering if there is a way of Mathematica to read a string or number and create variable with that name.
For instance imagine that I have a file with the word data1. I would want to create a ...
2
votes
1
answer
315
views
Most efficient way to read data from file in Mathematica
So I am having trouble because I am trying to do with Mathematica what is equivalent do "sscanf" with C basically.
I will have a text file with a number of specifications:
data1 data2 data3 ....
3
votes
1
answer
344
views
How to load a package? [closed]
I am new to github and loading github pacakges on Mathematica. I'm trying to follow examples from here. I used the PacletDirectoryLoad to load the packge from github but I get the following error. Any ...
1
vote
1
answer
73
views
Save/Export "any" mathematica window in .nb
Can I call this (a tutorial page) a mathematica notebook?
At least it is a kind of mathematica window, which looks like a common .nb file.
Is it possible to Save/Export this mathematica window in .nb ...
1
vote
0
answers
59
views
Entire process of "hyperlink of paclet" to "location of real file"?
Hyperlink[AAAAA, "paclet:ref/ModularInverse"]
AAAAA
If I click AAAAA, then a tutorial notebook for ModularInverse.nb ...
0
votes
0
answers
56
views
Fullpath of image in tutorial?
Is it possible to figure out the fullpath of an image in tutorial ?
For example, we can find an image of duck in tutorial/ImageProcessing.
But it is not easy to figure out the fullpath of the image.
<...
0
votes
1
answer
136
views
Delete specific files within a directory. How can i do it?
I'm a teacher and I have a lot of files (hundreds) with different names in different directories *for example "religion guide.docx","natural sciences guide.pdf" ,"Algebra 2 ...
0
votes
1
answer
67
views
WriteString does not keep the input format for a^2 + b^3?
I have a series of expression which is added one by one, not all at once, to a file (OUT.nb). for some of them that has POWER format (a^2 + b^3 ), WriteString cannot write it correct. Also I tried ...
0
votes
0
answers
114
views
Notebook won't save
Running Mathematica 13.0 (home edition) on macOS Monterey Version 12.5
I worked on an existing notebook this morning and saved the notebook at 11:05 AM without incident.
After further work, some 20 ...
2
votes
4
answers
410
views
How do I (efficiently) compare the n-th line in file A with the n-th line in file B?
I have two files, a.txt and b.txt. Both files contain numbers only, one number per line. Here is the beginning of ...
0
votes
0
answers
42
views
Is it possible to serialize NDSolveValue results for use in other notebooks?
I would not be surprised if this has already been addressed and I am overlooking it somehow.
I have a fairly long running NDSolveValue[]. I am developing a post-...
3
votes
0
answers
115
views
Dark mode documentation center
I saw some posts that modify or add some Mathematica files to change the interface of Mathematica's notebooks. Are there files that determine the background color of the documentation center ? I am ...
6
votes
1
answer
1k
views
Save loop output in a data file
I started working on Mathematica today. I'm trying to save the result of a loop in a file as a column, very simple to do, but hard for someone who doesn't know Mathematica syntax. Here is my code:
<...
2
votes
0
answers
92
views
FileNames error (General::dirdep) with long Windows path names
I'm trying to use Mathematica to analyse data that's saved (by my colleagues) to https://drive.google.com/ but I have run into a problem with the full pathname of files exceeding Window's limit of 239 ...
3
votes
1
answer
78
views
How do I import a file only when it is modified?
I am trying to create a Dynamic code that will Import the contents of file only if it has been modified. I tried the following ...
1
vote
1
answer
50
views
Temporarily prevent/allow exporting to specific folders
Is it possible to temporarily
Q1) prevent exporting to specific folders ?
Q2) allow exporting to only specific folders ?
Whenever mathematica is about to process ...
31
votes
6
answers
1k
views
What secrets are hidden away in your init.m and where do you place it? Please help me build the ideal init.m
My init.m Feels Like it's Missing Something
Although I am familiar with about a dozen or so programming languages I am only sort of, kind of, halfway competent in about three. MMA with it's boxes, ...
6
votes
2
answers
1k
views
File Path name copy&paste- single/double backslash problem
Shift+RightClick a file on windows explorer and select 'copy as path', then ctrl+v paste to mathematica notebook, then apply FileExistsQ :
ex1)
...
0
votes
0
answers
95
views
Reading an old file with newer versions of Mathematica
So I was given code for mathematica software in the form of an nb-file, but my mathematica sofware isn't reading it or detecting an nb file in my computer. I'm assuming this code was done a few years ...
3
votes
1
answer
70
views
RunProcess : Save directly to Mathematica Variable
I can convert mysource.jpg to myresult.jpg using an external program myprog.exe, and set a ...
3
votes
3
answers
175
views
Regular Expressions in FileNameJoin[]
I'm attempting to create a list of folders that match a particular pattern.
For example, consider I have the following files in a directory structure:
...
1
vote
0
answers
718
views
Creating a function, saving it in a file, and calling it in another file
I'd like to know how to wrap up a function in a file an then how to call it in another file. For example, I've the following long piece of code which is used to create the function PlotExplorer. I ...