Message Boards Message Boards

0
|
2685 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Change file extension

Posted 1 year ago

Dear All, I have to open two files that have the same name, but different extension. In the same directory I have one binary file (i.e test.bin) and one text file (i.e. test.txt). I use this string to open the bin file

NAME = SystemDialogInput["FileOpen"];

Now Name is C://path//test.bin

Is there the possibility to define in an automatic way

NAME2=C://path//test.txt

Thank you very much and best regards

POSTED BY: Bruno Vusini
3 Replies

Bruno,

here is one handy way to select txt-files using SystemDialogInput:

(* specific directory, e.g. home directory: *)
dir = $HomeDirectory;
filename=SystemDialogInput["FileOpen", {dir, {"Text-Data" -> {"*.txt"}, "Simply Everything" -> {"*"}}}]
POSTED BY: Henrik Schachner

Assuming those are the only two files in that directory with the name "test"

{name1, name2} = Filenames["test.*", "C://path"]
POSTED BY: Rohit Namjoshi
Posted 1 year ago

Dear all,
I found the solution by myself. I used this construct:

NAME2 = FileNameJoin[{DirectoryName[NAME], 
    F = FileBaseName[NAME] <> ".txt"}];

Maybe it can help. Best regards.

POSTED BY: Bruno Vusini
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract