Message Boards Message Boards

GROUPS:

Change file extension

Posted 6 days ago
192 Views
|
3 Replies
|
2 Total Likes
|

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
Posted 6 days 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

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

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

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
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