DataBrowser Folder Versioning Button

// This installs or removes a VersionFolder button in the DataBrowser
// The VersionFolder button will create a duplicate of the currently selected data folder
// with a date+time stamp appended to it:  'folder name'YYMMDDHHSS
// Copy this to the procedure window, compile, open a Data Browser,
// and then type InstallVersions() on the command line
// Select a data folder to version and click the VersionFolder button
// Remove the button by typing RemoveVersions() at the command line
// This also works with multiple data folders selected ... it will parse and run the command on each one
// It may choke on data folders with long names!

#pragma rtGlobals=1

Function InstallVersions()

    Execute/P/Q/Z "ModifyBrowser appendUserButton={VersionFolder,\"StoreFolderVersion(%s)\"}"  
    return 0


Function RemoveVersions()

    Execute/Q/Z "ModifyBrowser deleteUserButton=VersionFolder" 
    return 0


Function StoreFolderVersion(df)
    DFREF df
        // return if this is not a data folder

    if (DataFolderRefStatus(df)==0)
        return 0

    // uncomment this next portion if you would like to avoid versioning the Packages data folder

//  if (DataFolderRefsEqual(df,root:Packages))
//      return 0
//  endif
        // get information about the data folder

    string cdf = ParseFilePath(1,GetDataFolder(1,df),":",1,0)
    string sdf = ReplaceString("'",GetDataFolder(0,df),"")
        // create the new data folder name

    string currDTS, vdf
    sprintf currDTS, "%s%s",secs2date(DateTime,-2,":")[2,9],secs2time(DateTime,2)
    sprintf currDTS "%s%s" sdf, ReplaceString("'",ReplaceString(":",currDTS,""),"")
    sprintf vdf, "%s%s", cdf, PossiblyQuoteName(currDTS)
        // if the new already exists, do not overwrite

    if (DataFolderExists(vdf))
        return 0

       // make the new data folder
    DuplicateDataFolder df, $vdf
    return 0





Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More