Automatically import many text files (from any directory on my pc)

Anastasis Panayi's icon

Hello,
I have a patch that needs 4 text files(i have them in a directory on my desktop) to be uploaded in order to see if they are identical(like dna test).
I just can't find the way to upload them all together automatically.
How can i do that?
Thank you!

vichug's icon

if they are in the same folder, and if you know their name, you can input just the name of the folder with [opendialog folder] for instance

vichug's icon

then use [sprintf] or [combine] to append the name of the files, using one object for each file. But it's a bit unclear what you want to do so hard to help more precisely :
*with what, in max, do you intend to "upload" the files ?
*what do you want to trigger the uploading : one button, on startup, selecting a folder ?
*will those 4 text files be always the same ? do you need saving them too ?
if you provide a part of the patch it will be easier to help you

Anastasis Panayi's icon

Thank you very much for your early response!

A friend gave me this patch i attached you, i hope it helps.
I actually want it to be flexible with the names of the files if possible.
I don't know if there is a way to take the files with order (txt1, txt2, txt3, txt4) or something like linux where you say 1*.txt meaning anyfile starting with "1"then having anything else and ending with ".txt"....
I want this to happen with a button or on startup (lets keep the button for the moment).
Those files wont be the same.
I hope i helped you understand.

Thank you very much for your time!

dna.maxpat
Max Patch
vichug's icon
Max Patch
Copy patch and select New From Clipboard in Max.

hm the patch is... a little bit messy :D
so in this patch each time i click on the toggle, i have to select a file
so is that what you want ? select several files with only one click ?

vichug's icon

"I don’t know if there is a way to take the files with order (txt1, txt2, txt3, txt4) or something like linux where you say 1*.txt meaning anyfile starting with "1"then having anything else and ending with ".txt"…."
so that would scan a folder ?
both things are possible, but you really have to decide what you want...

Anastasis Panayi's icon

I know it is a mess... i am so sorry!!
Great! i like this patch you attached!
Ok i will try to decide.
I want to load all text files from a specific file with a single click

Thank you very much!!!

vichug's icon

"I want to load all text files from a specific file with a single click"

Do you mean :
"I want to load all text files from a specific *folder* with a single click"
?

Max Patch
Copy patch and select New From Clipboard in Max.

then it's something like this :

in place of the opendialog fold you can set a folder path you know in message box and click on it. Then, with the regexp, you can use the regular expression you want in a near-linux style - it's a bit difficult to grasp at start, but ask if you need help :)

Anastasis Panayi's icon

Yes that's what i meant! I am sorry!
This is awesome!!!
Thank you very much for your help and your patience!! ^_^

Anastasis Panayi's icon

Hello =)
Can i read those text files??
I want to use them.
are they stored anywhere?
Thank you!

Anastasis Panayi's icon

I found the way to get the files!! Thank you!! =)
There is one more thing that i might need. Can i filter umenu's context(show only txt files or by name e.g. all the files having "35" in their name).
Thank you!

tst13-auto-load-txt-help.maxpat
Max Patch
vichug's icon
Max Patch
Copy patch and select New From Clipboard in Max.

yes, but you have to do the "filtering" before the files enter the umenu ; and it's wihtin the regular expression (ther regexp object) :

vichug's icon

in the regular expression : the point ( . ) means "any character" ; the multiply sign ( * ) means "preceding character occur zero or more times" ; so after the point ( .* ) it means "any character zero or more times" ; the 35 means 35 ; the double slash ( \\ ) means "get rid of particular meaning of the forthcoming character" ; so before the point ( \\. ) it means "an actual point" and the txt means txt. Regexp will output ; through its "substrings" outlet ; any string of characters that matches the shape that is described with the symbols i just explained so : it begins wiht zero or more of any character, must have a 35 in it, then zero or more of any characters, then end with .txt.

Anastasis Panayi's icon

Wow!!
35 was random. I meant a txt file with name book35.txt or 35book.txt.... for example.
Anw you were very helpful!
This is what i call explain in detail!! ^_^
Thank very much!!!

Anastasis Panayi's icon

Can i copy files from one directory to another one on my pc through a patch??
Thank you!