0

Is there a way within a praatscript to query the path and filename of an object.

I want to save a textgrid to the same file I opened (overwite it)

I was think of something like:

    selectObject: n
    type_name$ = selected$ ()
    file_name$ = some_way_to_query_this..., n
    type$ = extractWord$ (type_name$, "")
    if type$ == "TextGrid"
        runScript: "save.praat", file_name$
    endif
badner
  • 768
  • 2
  • 10
  • 31

3 Answers3

1

No. Objects in Praat do not store information about their location on disk because most objects will never exist on disk at all. Objects are not files.

If you are reading an object from a file, and then want to store the object to the same location, then you should store that information elsewhere yourself.

jja
  • 2,058
  • 14
  • 27
0

This isn't an answer to your question but to the situation. Depending on how you open the textgrid, you could throw the filename into a string variable and then save to the same name.

file$ = "C:\Users\Me\Desktop\praat\example.TextGrid"
Read from file: file$
Set tier name: 1, "this"
Set tier name: 2, "that"
Save as text file: file$
0

This answer is quite late but it could be still useful to someone...

The file name, if it exists, can be shown with the Info command.
After selecting an object:

object_info$ = Info
file_name$ = extractLine$(object_info$, "Associated file: ")
writeInfo: file_name$