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
2 votes
0 answers
29 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 ...
user avatar
  • 71
3 votes
1 answer
67 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 ...
user avatar
  • 8,337
1 vote
1 answer
46 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 ...
user avatar
  • 2,877
28 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
243 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,877
0 votes
0 answers
70 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
55 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,877
3 votes
3 answers
90 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
  • 196
1 vote
0 answers
33 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
77 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,114
4 votes
1 answer
117 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
  • 443
1 vote
0 answers
55 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
47 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
48 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
40 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
327 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
49 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
187 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.5k
11 votes
2 answers
383 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
36 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
83 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
67 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,832
1 vote
1 answer
86 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
32 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
120 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
  • 123
3 votes
1 answer
70 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
  • 960
2 votes
3 answers
174 views

Sophisticated read data from .txt file

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

select partially matching filenames

I have two lists of files with slightly different naming conventions ...
user avatar
1 vote
0 answers
77 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
113 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
  • 658
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
146 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
103 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,837
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
54 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
97 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
57 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
57 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
62 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,837
2 votes
0 answers
57 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,837
2 votes
2 answers
207 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
111 views

How can I read this file?

I have to read and process a file that looks like this: ...
user avatar
  • 6,134
3 votes
1 answer
99 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
2 3 4 5
9