save folder question

Hi,
this is a repost from https://forum.audacityteam.org/t/dossier-de-sauvegarde/23909/1 I will translate my question in english to have a better chance to get an answer !

I want to deploy the new Audacity version 2.0 on many Windows computers (about 2000). We have Windows XP, Vista and 7. To do it, I create an msi with Advanced Installer in which I setup the app data folder of the default user. Since our computers have delprof, the new config is automatically imported. I also include the mp3 export files and related config.

Here is my problem, our users save their documents on the network. I can’t find a way to make them save in their U: at their first save action. Once they did it, the save box will open in the U: automatically for the next time.

It doesn’t seem to be in the audacity.cfg of the app data, neither in the current user registry. Can some one tell me where to configure the first save folder ?

Thanks.

As far as I know, the only way to tell Audacity about directories is…
Audacity > Preferences > Directories > Temp Files

I don’t know of any setting for Home or Save directory.

Koz

Audacity does remember, across a stop-start, the directory that you last saved into. Therefore the information is stored somewhere. My guess would be in the Windows Registry.

No, to the best of my knowledge the project save directory is stored internally by the application every time a project is saved, and if a project has never been saved by the application before, it will use the working directory instead.

If you open or import a project or audio file, this over-rides the stored value and Save Project will then save from the directory opened or imported from, but the directory that over-rides is not stored. So on opening a fresh, empty project (even in the same session) and doing “Save Project As” immediately, you will always be presented with the directory last saved to, if any.

I know of no way to fool audacity.cfg into thinking the project save directory is something else. The only way I could see would be to associate Audacity with some file type that you wanted to open in Audacity such as MP3, then have the users execute the MP3 from U: instead of execute Audacity.

So do I assume you wish to vote for a default project save path?

If by saving you mean “export” (which I doubt) this is stored in audacity.cfg and can be forced even for a new installation for example:

[Export]
Path=C:\Users\gale\Desktop

Note the double backslashes in the path.

Another useful example:

DefaultOpenPath=C:\Program Files\Winamp

sets the open and import path.


Gale

I don’t but the original poster might.
Thanks,
Peter

Thanks for the infos… it seems I was not the only one to think about the registry. I will look at the default save project path later.

No current version of Audacity uses the registry to store information, it is always stored in the .cfg file. Nothing is stored “internally by the application” because it has no-where to write it. Things in memory are all lost when Audcaity is closed, except those written out to a file somewhere.

Let’s be very clear, there are multiple different ways to get a file out of Audacity:

  1. File > Export (including Export Selection but not Export Multiple)

  2. File > Export Multiple

  3. File > Save Project As (including Save Compressed Copy of Project)
    Each of them has a separate means to decide what the default location given to the user is.

  4. File > Export uses the “/Export/Path” preference to set the starting directory, i.e. the value of the “Path” variable under the “[Export]” section of the .cfg file. (see source code in src/export/Export.cpp)

  5. File > Export Multiple uses the “/Export/MultiplePath” preference to set the starting directory, i.e. the value of the “MultiplePath” variable under the “[Export]” section of the .cfg file.

  6. File > Save Project As does not provide a starting directory when opening the dialogue, unless the project already has a path associated with it to use.

In the last case I mean that if the project has been previously saved, we use the directory it was last saved in. If the project was created by opening a file, then we use the directory that file was in, and if neither, then we don’t use anything.

The last case means that the dialogue is opened with the default behaviour from wxWidgets. According to the documentation (http://docs.wxwidgets.org/2.8/wx_wxfiledialog.html) “If path is “”, the current directory will be used”, however on Linux with current wxGTK/GTK+ this isn’t true - the dialogue is opened at the recent directory list, which is what GTK defaults to when it isn’t given a directory to save in. Looking at the wxWidgets source it is clear that when the application does not provide a starting directory, GTK+ is left to make it’s own mind up where to start, which it is more than capable of doing:
http://developer.gnome.org/gtk3/3.0/GtkFileChooserDialog.html#gtkfilechooserdialog-setting-up

On windows the situation is more complicated only because of the strangeness of the Windows APIs. When the first Save Project As dialogue is opened, it goes wherever the OS would like to put it, because there is no starting directory. However when the user changes directory within that dialogue, the current working directory of Audacity is changed by Windows in the background (no, I have no idea why this is a good idea) to wherever the file gets saved. This will then be where the next Save Project As goes, until Audacity is closed where upon the working directory is lost.
Thus on Windows (well, NT-based Windows) it does seem that Audacity is “remembering” where a project has been saved to, but in fact the information resides in Windows and is altered there (without being visible to Audacity), until it is lost when Audacity closes.

The long and the short of which is that there is no way to set the starting directory for Save Project As by adding entries to the Audacity configuration file, the registry or anywhere else. You might be able to fake it by setting the working directory for Audacity when starting Audacity (in the shortcut properties) but this may cause other things not to work.

But, in neither case, does the user have control of these via Edit > Preferences > Import/Export. So these aren’t really “Preferences” are they? They are “Default Destinations” imposed upon the user by the developers. A “Preference” is something which I prefer, not something that a developer forces upon me.

And therefore is, almost certainly, being stored somewhere in the Registry?

Is this true? I was under an impression that Audacity would direct me to the same Save Project As location after the stop-start of Audacity. Or am I suffering from “false memory” syndrome?

Not exactly imposed by the developer. Audacity is remembering the last save location you entered in the “Export” or “Export Multiple” dialog boxes. Lots of things are stored in the .cfg file that are not accessible through the Preferences dialog.

– Bill

The behaviour is not 100% consistent, but on Win 7 (less so on XP) the last project save directory almost always not only survives Audacity quit but survives reboot. I base that on a considerable amount of practical observation. I “thought” I had seen some developer explain this as some kind of “internal saving” but I’m kind of relieved if Windows is controlling this which would be more understandable.

If Windows is choosing the Audacity working directory (whenever the project save directory hasn’t been influenced by an open or import), the mechanism for deciding the working directory is still confusing. If I import into a project from a folder I commonly import from (but a different folder to the folder that Save Project opened to before the import), then quit and restart Audacity, Save Project will usually open to the folder I last imported from.

If I import from a folder I hardly ever import from, that folder seems to be disregarded, so on quit and restart of Audacity, Save Project reopens to the last folder it saved to. I therefore assume that most recently used lists are being queried somehow in coming to the decision. But I’m in agreement Audacity is not writing to the registry itself.

That seems to me to give more force to having a Preference for the “save” and " export" directories. Choice for both could be 1) for a fixed directory; 2) always remember the last used; or 3) remember the last used unless a file was imported. 3) would be very popular I think for those who want to import then export over the same file. System admins would I think appreciate the save directory preference because they could then force first project save to the location they wanted (as they can already force first export location).

Also if the Audacity default preference was to use 1) a fixed directory (probably the user’s documents folder on Windows) this would be a lot less unpredictable/inscrutable than what happens now.

So do we have PGA’s vote for some kind of save and export preference?

You mean “Start in”? No, not with Audacity (nor with many apps on Win 7). Save Project still opens as I described.

Thanks for your input.



Gale

Yes, something along the lines you describe in your post above would get my vote! Thanks.

I can confirm that on XP running in Virtualbox and in Vista on real hardware.
The behaviour has been consistent in my tests - somehow the last save directory is remembered even after a system reboot (though I’ve no idea how this happens).

I can confirm that works, and I see no ill effects.
If the working directory in the shorcut properties is set immediately after installation (before any projects are saved) then that becomes the “default” save directory. The setting is overridden as soon as a project is saved to a different directory and the last save directory becomes the “default”.

Windows remembers the last “Save As…” location in the registry.
On XP it is at

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerComDlg32LastVisitedMRU

and on my Win7 system I found the entry for Audacity at

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerComDlg32LastVisitedPidlMRULegacy

I did a quick test on my XP machine.
Started Audacity and did a “Save Project As…” to check the last location I saved an Audacity project in:

C:Documents and SettingsragnarMina dokumentMin musiksavetest

Closed Audacity and fired up regedit. Each subkey holds a value for one specific application. I looked through the subkeys and found the entry for Audacity in subkey k:

Yup, that’s the path alright.

Manually hacked the path to Z:savetest:

Note that the entries are 16-bit Unicode (on XP, they’re more complex on Vista and 7).

Started up Audacity again and now the “Save Project As…” dialog points to my new registry-hacked-in path.

Z:savetest

So, it looks like you’ll be able to control the initial save location by careful registry editing :sunglasses:

See also http://computer-forensics.sans.org/blog/2010/04/02/openrunsavemru-lastvisitedmru

Ragnar

Thanks Ragnar, that solves one little mystery. :slight_smile:

Thanks to Ragnar for his investigations. This would still seemingly require some fiddling around for the sysadmin to force the Save Project directory. I think you would probably have to previously created the value by saving in Audacity to produce the correct values. Also the new binary value (at least on Windows 7) has to have the next name in the list e.g. 12 if the last one was 11. Adding a new value with an arbitrary name is ignored.

Interestingly the same key is used for the same executable name irrespective if there are other applications with the same name in in different directories.

However creating a registry value before running Audacity doesn’t seem to interfere with being able to force other paths in audacity.cfg.

I’ll add PGA’s vote for Preferences for save and export directories.

On what operating system, and where exactly are you setting the working directory? I only know “Start in”. Even setting that after installation, before saving a project and after deleting the above registry value does not set the Save Project directory. It does set the “open” directory, but then I can set that via audacity.cfg anyway.


Gale

I tested on both Vista (real machine) and XP (in Virtualbox), but there was an error in my test method. :blush:
When I created a folder to save to, I created a file in that folder (New Text Document.txt) so that I could more easily copy the full path (rather than typing it into the shortcut “Properties > Start In” manually)
If you create a new txt file in the location and then change the shortcut “Start In” properties, then that folder becomes the “Save As” folder.
This probably has implications for Ragnar’s method which I now suspect will not be reliable in all cases.

This Windows mechanism seems so messed up, I’m now +1 for an Audacity Preference for the Save folder (not a GUI setting, just an entry in the audacity.cfg file).

You are right about that, messed up is only the start of it. I have delved a bit deeper into it and found that Windows (or rather the File Open Common Dialog) uses quite an elaborate decision tree when deciding which folder it presents to the user. I also found that Windows will clean up the registry entries if left unused for some time, i.e. if you haven’t used Audacity for a couple of weeks you’ll find that Windows has forgotten where you used to save your files. There’s plenty more pitfalls, making the registry hack method less appealing than it appeared yesterday. I wouldn’t recommend it.


Ragnar

I used a polite word, but it wasn’t the first word that came to mind :wink:

I never find it “appealing” to hack the registry …

“Stay away from the dark side Luke”

WC

Hi,

I set a default folder using Explorer Reg keys. This reg key stores the last folder used by a user within audacity, so the user can change this just by saving to a different folder. To persist it, you’d have to create these values prior to each launch. In a corporate world that could be done using AppSense, App-V, RES etc.

In a non-corporate world, this could simply be a batch file which runs regedit.exe /s MyRegFile.reg.

The following reg keys/values set the default folder to N:

[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerComDlg32LastVisitedPidlMRULegacy]
“MRUListEx”=hex:00,00,00,00,ff,ff,ff,ff
“0”=hex:61,00,75,00,64,00,61,00,63,00,69,00,74,00,79,00,2e,00,65,00,78,00,65,
00,00,00,14,00,1f,50,e0,4f,d0,20,ea,3a,69,10,a2,d8,08,00,2b,30,30,9d,19,00,
2f,4e,3a,5c,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

If you want to change the value from N: to something else, simply add the above reg fragment into the registry and then you will see the HEX code displayed, which can be modified manually to point to your folder of choice.

Or, simply use Audacity to save a file to your chosen location and browse to the above reg key and export it.

Paul