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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
35 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....
jpskin's user avatar
  • 21
0 votes
0 answers
45 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 ...
J Tyson's user avatar
  • 113
5 votes
5 answers
642 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 ...
bill s's user avatar
  • 68.3k
1 vote
1 answer
76 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 ...
azerbajdzan's user avatar
  • 9,903
2 votes
0 answers
120 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: <...
Erfan's user avatar
  • 159
0 votes
0 answers
47 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 ...
michelangelov's user avatar
1 vote
0 answers
60 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: ...
Granger Obliviate's user avatar
2 votes
1 answer
127 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 ...
Granger Obliviate's user avatar
2 votes
1 answer
128 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 ...
florin's user avatar
  • 1,632
1 vote
1 answer
48 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::...
Cheng Tao's user avatar
  • 151
3 votes
2 answers
150 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 ...
florin's user avatar
  • 1,632
0 votes
0 answers
36 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&...
Sudip Chakraborty's user avatar
0 votes
1 answer
42 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? ...
AAA's user avatar
  • 197
0 votes
1 answer
54 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, ...
Armin Vollmer's user avatar
2 votes
2 answers
99 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: ...
John Taylor's user avatar
  • 4,681
4 votes
1 answer
75 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 ...
rhermans's user avatar
  • 36.2k
0 votes
0 answers
70 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 ...
Granger Obliviate's user avatar
2 votes
1 answer
205 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 ....
Granger Obliviate's user avatar
3 votes
1 answer
187 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 ...
grading's user avatar
  • 251
1 vote
1 answer
66 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 ...
imida k's user avatar
  • 4,047
1 vote
0 answers
56 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 ...
imida k's user avatar
  • 4,047
0 votes
0 answers
52 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. <...
imida k's user avatar
  • 4,047
0 votes
1 answer
88 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 ...
Pamela's user avatar
  • 55
0 votes
1 answer
64 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 ...
Azzurro94's user avatar
  • 499
0 votes
0 answers
66 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 ...
Jagra's user avatar
  • 14.3k
2 votes
4 answers
405 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 ...
Klangen's user avatar
  • 989
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-...
Doug Kimzey's user avatar
  • 2,259
3 votes
0 answers
101 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 ...
userrandrand's user avatar
  • 5,737
6 votes
1 answer
995 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: <...
nosumable's user avatar
2 votes
0 answers
76 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 ...
Simon's user avatar
  • 71
3 votes
1 answer
75 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 ...
user13892's user avatar
  • 9,113
1 vote
1 answer
47 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 ...
imida k's user avatar
  • 4,047
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
933 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) ...
imida k's user avatar
  • 4,047
0 votes
0 answers
86 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 ...
user5896534's user avatar
3 votes
1 answer
68 views

RunProcess : Save directly to Mathematica Variable

I can convert mysource.jpg to myresult.jpg using an external program myprog.exe, and set a ...
imida k's user avatar
  • 4,047
3 votes
3 answers
136 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: ...
Karl's user avatar
  • 196
1 vote
0 answers
465 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 ...
Gennaro Arguzzi's user avatar
1 vote
2 answers
168 views

How to search a directory of nb files for a string?

I would like to find a particular string in a set of nb files in a directory but am having problems interpreting the results of my code. Here's a simple example: In directory d:\mathematica, I have ...
josh's user avatar
  • 2,340
4 votes
1 answer
286 views

Resolve absolute path to Documentation Notebook

We can easily create clickable hyperlinks for Documentation pages like the following: {URL["paclet:ref/Set"], Hyperlink["paclet:ref/Set"]} But ...
Alexey Popkov's user avatar
1 vote
1 answer
41 views

How to change the format of ReadList

I have a quick question, please help me if you have an idea: 1- i need to read the data in another format, in the desired answer the records must be separated by &&, and without braces { } . ...
Azzurro94's user avatar
  • 499
1 vote
0 answers
157 views

Set filename using variable [closed]

Is it possible to use variable filename to Export in mathematica? For example, I want to export a number of files like ...
prantik sarmah's user avatar
4 votes
0 answers
54 views

Function for identifying wasteful cells (e.g. needless large graphics) - does this exist already?

I noticed that I have a bad habit of saving notebooks with huge graphics in them and it's starting to impact storage and load times a little much. I figured I could make a routine to point out the few ...
Trev's user avatar
  • 763
2 votes
0 answers
75 views

family photo album,how to optimize its realization?

I am Beezy, the eldest daughter of the couple. I have a lot of photos on paper and I want to make a photo album for my parents, but the task is titanic. First I use a scanner, to scan the photos that ...
BeTDa's user avatar
  • 480
1 vote
1 answer
57 views

operating on text files in different folders

I have a large number of folders (say, m) in a directory and each one of them has n1, n2, ..., nm numbers of text files. I have to perform a mathematical operation on these text files which will ...
user49535's user avatar
  • 1,185
5 votes
1 answer
677 views

How to merge multiple .nb files into one notebook in mathematica

I have 10 different notebook files which I want to combine into a single .nb file. I know I can copy-paste all the cells of those 10 files to a new notebook window and then save it as nb. I can do so ...
Aman Kushwaha's user avatar
5 votes
1 answer
249 views

How to run wolfram code from the finder in macos?

I'd like to run wolfram code (probably a .wls script) on a file or set of files by selecting them in the finder and using Right-click > Services. For example, ...
M.R.'s user avatar
  • 31.2k
12 votes
2 answers
520 views

Possible bug in 12.3: NotebookDirectory[] returns not the notebook's own directory, but that of an also opened copy of that notebook

Bug introduced in 12.3, Resolved in 13.1 I am using Windows 10 and found a bug concerning NotebookDirectory (and also ...
dnet's user avatar
  • 943
0 votes
0 answers
49 views

Export data to file

I have a function f[x,y,z,i] that returns the solutions {x1,y1,z1} for each step "i". I would like to use a repeating command (such as Do[...]) to get the outputs of this function f saved ...
dasV's user avatar
  • 13
1 vote
1 answer
177 views

How to move all files of a folder to another folder, preserving relative file paths, and overwriting old files?

I have the following folder structure Main +updates +newversion +subfolder1 +subfolder1 I would like to copy the content of the subfolder "newversion" ...
Giorgio Busoni's user avatar

1
2 3 4 5
10