When I import an audio file to do a quick edit I almost always want to Export it right back where it came from.
Currently Audacity stores the previously used save path for Export. So if I Export a file to d:songs/rock/artist/album then Import one from c:music/pop/artist/album, do a bit of editing then choose File>Export…, the file dialog opens on the OLD directory ( d:songs/rock/artist/album ) and (at least on Windows) the file save dialog is really clunky and getting from way down in d:songs/rock/artist/album to the location I want ( c:music/pop/artist/album ) is a lot of clicking.
I realize that for some workflows having the Export dialog always open in the same directory is good but for my workflow (after Import) I want it to open for Export in the Import directory. As it turns out this is easy to accomplish.
First, add a new public wxString mImportPath to the AudacityProject class (it does not really matter where as long as it is in a public section), so in Project.h around line 389 it seems that on Linux it might really matter where in the header the new variable goes); so, in Project.h at the very end of the file:
// Are we currently closing as the result of a menu command?
bool mMenuClose;
public:
wxString mImportPath;//efm5
DECLARE_EVENT_TABLE()
};
#endif
We will not initialize mImportPath as we rely on wxString to be created empty.
Next we need to store the path of the Import directory, so in Project.cpp around line 3372:
bool AudacityProject::Import(wxString fileName, WaveTrackArray* pTrackArray /*= NULL*/)
{
//efm5 start
AudacityProject * project = GetActiveProject();
wxFileName tempFilename(fileName);
project->mImportPath = tempFilename.GetPath();
//efm5 end
Track **newTracks;
Finally, when we Export we need to use the stored path, in Export.cpp around line 542:
maskString.RemoveLast();
//efm5 start
if (mProject->mImportPath.IsEmpty())
mFilename.SetPath(gPrefs->Read(wxT("/Export/Path"), ::wxGetCwd()));
else
mFilename.SetPath(mProject->mImportPath);
//efm5 end
mFilename.SetName(mProject->GetName());
while (true) {
FileDialog fd(mProject,
This is all tested against SVN HEAD 17Feb2011 but only on Windows7. If you Drag ‘n’ Drop a supported audio file on the program icon or a Project window or choose the menu items File>Import>Audio… then choose File>Export the Import path will be used when opening the file dialog. If you open an empty Project and record or generate audio and choose File>Export the OLD path saved in the configuration file will be used.
In the above code I have included a line or two before and after my changes for continuity. I have noted or wrapped changes with //efm5 comments.