Skip to main content

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
59 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.}, {...
Delaram Nematollahi's user avatar
0 votes
0 answers
40 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 ...
Delaram Nematollahi's user avatar
1 vote
0 answers
46 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 ...
CuriousMind's user avatar
2 votes
1 answer
71 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: ...
user13892's user avatar
  • 9,443
1 vote
1 answer
60 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 ...
Teg Louis's user avatar
8 votes
2 answers
176 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 (...
Kuba hasn't forgotten Monica's user avatar
0 votes
0 answers
27 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 ...
Neil Geismar's user avatar
2 votes
0 answers
37 views

Weird behaviour of Image`ImportExportDump`ImageReadPNG

Here is the problematic code, ...
matheorem's user avatar
  • 17.2k
0 votes
1 answer
42 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
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 ...
J Tyson's user avatar
  • 132
6 votes
5 answers
851 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
  • 69.2k
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
  • 18.9k
3 votes
0 answers
133 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
  • 169
0 votes
0 answers
65 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
73 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
175 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
135 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,798
1 vote
1 answer
74 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
166 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,798
0 votes
0 answers
55 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
51 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
78 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
101 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
  • 5,827
4 votes
1 answer
81 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.7k
0 votes
0 answers
73 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
269 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
273 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
  • 261
1 vote
1 answer
71 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,295
1 vote
0 answers
58 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,295
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. <...
imida k's user avatar
  • 4,295
0 votes
1 answer
124 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
66 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
79 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.4k
2 votes
4 answers
406 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
  • 1,009
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,279
3 votes
0 answers
109 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,912
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: <...
nosumable's user avatar
2 votes
0 answers
85 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,443
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 ...
imida k's user avatar
  • 4,295
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) ...
imida k's user avatar
  • 4,295
0 votes
0 answers
91 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
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 ...
imida k's user avatar
  • 4,295
3 votes
3 answers
156 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
  • 316
1 vote
0 answers
621 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
182 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,412
4 votes
1 answer
320 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
175 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

1
2 3 4 5
10