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
23 votes
6 answers
721 views

What secrets are hidden away in your init.m file and where do you place it? Please do share!

Help Build init.m Best Practices By Sharing or Critiquing Code Some of our most essential code is hidden away in a file that we can just drop and forget. Although contents of this infamous file should ...
6 votes
2 answers
209 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) ...
user avatar
  • 2,451
0 votes
0 answers
69 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 ...
user avatar
3 votes
1 answer
52 views

RunProcess : Save directly to Mathematica Variable

I can convert mysource.jpg to myresult.jpg using an external program myprog.exe, and set a ...
user avatar
  • 2,451
3 votes
3 answers
89 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: ...
user avatar
  • 177
1 vote
0 answers
32 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 ...
user avatar
1 vote
2 answers
73 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 ...
user avatar
  • 1,084
4 votes
1 answer
94 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 ...
user avatar
1 vote
1 answer
35 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 { } . ...
user avatar
  • 351
1 vote
0 answers
54 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 ...
user avatar
0 votes
1 answer
43 views

Errors with opening and closing file streams

I'm fairly new to Mathematica programming. I'm writing a small program that needs to handle text file streams to write output to and read input from them. Although I'm closing the file streams at the ...
user avatar
4 votes
0 answers
47 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 ...
user avatar
  • 611
2 votes
0 answers
65 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 ...
user avatar
  • 480
1 vote
1 answer
38 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 ...
user avatar
  • 973
5 votes
1 answer
301 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 ...
user avatar
0 votes
0 answers
43 views

Run .exe file from Mathematica with another file as argument

I'm dealing with three files in my project : A mathematica Notebook containing all the properties for the calculation which generates a .inp file A .inp file (Input for the .exe file) A .exe file (...
user avatar
5 votes
1 answer
185 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, ...
user avatar
  • 30.3k
11 votes
2 answers
365 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 I am using Windows 10 and found a bug concerning NotebookDirectory (and also NotebookInformation) in 12....
user avatar
  • 903
0 votes
0 answers
34 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 ...
user avatar
  • 13
1 vote
1 answer
76 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" ...
user avatar
1 vote
1 answer
59 views

How to extract the data from the given filename?

Consider a few files with filename structure data/Neutrino distribution functions/NAME_distribution_mass=XX.0_theta=0.YY.txt where XX/YY may have an arbitrary ...
user avatar
  • 3,542
1 vote
1 answer
84 views

Read arbitrary line from CSV file

Consider some large ".csv" file. For instance: ...
user avatar
1 vote
2 answers
44 views

For loop over several arguments with different length each

I have a set of text files named in indexed way d1, d2, d3, d4, d5, d6, d7, d8, d9. I want to read them by Mathematica and export them back with other index names N(s1f1+s1f1), N(s1f1+s2f2), N(s1f1+...
user avatar
  • 105
0 votes
0 answers
30 views

GraphicsGrid $\to$ Beep "The shared stylesheet "Stylesheet-review-topics.nb" could not be \ found. The default stylesheet will be used instead."

12.0.0 for Microsoft Windows (64-bit) (April 6, 2019) I have a notebook in which using GraphicsGrid causes a beep "The shared stylesheet "Stylesheet-review-topics.nb" could not be found....
user avatar
0 votes
2 answers
102 views

Exporting a file into a subdirectory of notebook

How can I create a directory in a notebook directory and export a file (resulted from that notebook) to created subdirectory?
user avatar
  • 103
3 votes
1 answer
67 views

Adding spelling dictionary to Mathematica

I was hoping this could be easy, but it's not. I need to add the Czech spelling dictionary to Mathematica. I copied the two files: cs_CZ.aff and cs_CZ.dic in to the /Applications/Mathematica.app/...
user avatar
  • 215
1 vote
0 answers
23 views

Autocomplete file argument for custom function

When typing Import[" in a notebook Mathematica suggests to autocomplete the file path you want to enter or choose a file using the GUI. Is there a way to let a ...
user avatar
  • 928
2 votes
3 answers
166 views

Sophisticated read data from .txt file

I have following .txt file: ...
user avatar
  • 361
0 votes
1 answer
49 views

select partially matching filenames

I have two lists of files with slightly different naming conventions ...
user avatar
1 vote
0 answers
74 views

Mathematica crashed, now my file's all in text. How do I get it back to normal?

I was completing an assignment for a mathematica class, and ran a large set of data that crashed the program. I had to restart my computer, and when I relaunched mathematica, my file looks like this (...
user avatar
1 vote
1 answer
52 views

Import a file that is located in one of three directories?

Import a file that could be in one of three directories I want to import a file called image.png. I know it is either in dir1, <...
user avatar
5 votes
1 answer
112 views

How to determine the file type of a .m file?

Both Mathematica and MATLAB widely uses .m files, but with diametrically different syntaxes and usage. Currently WRI is moving towards the ...
user avatar
  • 648
1 vote
1 answer
51 views

Import 4 data columns and drop one of them [closed]

I would like to import 4 columns of data from a Dat-file(Fortran) and then drop the fourth one to use ListPlot3D and repeat this to drop the third one. When I used ...
user avatar
5 votes
1 answer
151 views

Visualizing directories--a cleaner view of a helpful older post

I am looking to make graphics of a folder hierarchy, and this old post was very helpful. However, this method gives the whole file path for each node, which makes a complete mess in the directory I ...
user avatar
  • 623
0 votes
0 answers
30 views

Using CloudDeploy[FormFunction[...]], how to let a user give a directory path as input?

I want to creat a CloudDeployed FormFunction which lets a user give the path to a directory on their local computer as an input. ...
user avatar
3 votes
0 answers
138 views

ResourceFunction cannot find cached local version

When I try to use ResourceFunction it doesn't find a file. I'm afraid it's because my user name on Windows include spaces and an "é". ...
user avatar
  • 403
0 votes
0 answers
99 views

Why is my init.m not loading at startup?

The contents of init.m are placed inside an Initialization Cell so that some symbols are created in the Global` context and to prepend alternate paths to ...
user avatar
  • 1,787
1 vote
0 answers
22 views

Getting the largest integer filename in a Wolfram cloud folder?

I'm creating a Wolfram function which saves PNGs into a cloud folder called png. I'd like this function to save pictures in increments, like ...
user avatar
  • 2,975
0 votes
1 answer
53 views

Import and create a hexdump view of file

How would I go about creating a hexdump type of view of an imported binary file? for example, (format is ...
user avatar
  • 465
1 vote
2 answers
94 views

Making a notebook unsavable, so that I don't accidentally mess up the code

I have an algorithm in a notebook that I don't want to change. I used it regularly. I'm afraid I might accidentally modify a parameter. I'd like the notebook to be executable, perhaps editable, but ...
user avatar
  • 285
1 vote
1 answer
45 views

Reading specific data from files

I have a huge number of identically formatted .txt files. I would like to read some numbers at a specific position within the text file (row x, column y..) and put them in another file, then repeat ...
user avatar
  • 11
0 votes
1 answer
55 views

File Name is incorrect in Directory [duplicate]

This is my test. x = 1.; file2 = "sqrt2_2b.txt"; Do[x = x/2 + 1/x; x >>> file2, {5}] This code above I get the File name "file2". ...
user avatar
  • 1,601
0 votes
1 answer
61 views

How to load a function from an external notebook that creates a docked cells toolbar?

I coded a compact toolbar in its own file nbtaskmate.nb for various common notebook tasks which I would like to load onto any notebook I might have open with a ...
user avatar
  • 1,787
2 votes
0 answers
55 views

What are key differences between InputNotebook and EvaluationNotebook?

I am still new to Mathematica but advancing to a point of programming notebook and cell manipulations using native commands. Sometimes they call for specifying ...
user avatar
  • 1,787
2 votes
2 answers
201 views

Where to place the essential WSTP files in Visual Studio 2019?

I have Visual Studio for C installed in : C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC From https://reference.wolfram.com/language/tutorial/WSTPDeveloperGuide-Windows.html : "...
user avatar
3 votes
2 answers
110 views

How can I read this file?

I have to read and process a file that looks like this: ...
user avatar
  • 6,104
3 votes
1 answer
98 views

Is there a more practical way to remove backgrounds from a list of files in a folder on my computer?

Is there a more practical way to remove backgrounds from a list of files in a folder on my computer? Example: Imagine a folder with three image files... Unfortunately I waste time manually renaming ...
user avatar
  • 9,055
1 vote
0 answers
51 views

How to use export and schedule tasks to backup entire contents of an notebook at regular time intervals?

I am sorry I don't have any code to share so I would like your ideas. Although there is an AutoSave feature in Mathematica it lacks usefulness as it cannot be ...
user avatar
  • 1,787
2 votes
1 answer
36 views

ResetDirectory causes a fail on stored file names

Consider some directory dir with sub dirs and files. Our aim is to count the no of files in dir (not in sub-dirs, just the dir.) ...
user avatar
  • 902
1 vote
0 answers
42 views

How to test the existence of a file in a case-sensitive manner?

I noticed (using Mathematica 11.2 on Windows) that FileExistsQ["test.txt"] returns Trueeven if there only exists a ...
user avatar
  • 903

1
2 3 4 5
9