# 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.binIs there the possibility to define in an automatic way NAME2=C://path//test.txt Thank you very much and best regards
3 Replies
Sort By:
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 6 days ago
 Assuming those are the only two files in that directory with the name "test" {name1, name2} = Filenames["test.*", "C://path"] 
Posted 5 days ago
 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" -> {"*"}}}]