Open 03302024 opened 3 months ago
The VDF settings, including the "Search Directories", are stored in Settings.json in the VDF directory. JSON is a text format and can be easily modified with various scripting languages, so that the functionality could also be realized outside of VDF. (If no interaction with an already running VDF instance is necessary)
One way to get by with Windows board tools is e.g. powershell. The following ps1 script is a proof of concept providing the functionality you mentioned. (The .cmd only has the task to start the powershell script e.g. by drag&drop directories/files on it). Both files are designed to be copied into the VDF.GUI.exe directory.
_vdf_settingsmod.cmd
@echo off
Powershell.exe -ExecutionPolicy Bypass -File "%~dp0\vdf_settings_mod.ps1" %*
_vdf_settingsmod.ps1
Write-Host "Addding Path to VDF include list..."
# Check and prepare Arguments
$path_list = @()
foreach ($item in $args)
{
if ($item)
{
$new_dir = $item.TrimEnd('\')
}
if (!$item -or !(Test-Path -Path "$new_dir"))
{
Write-Host "Invalid argument ""$new_dir"" (no file or directory)."
continue
}
if (Test-Path -Path "$new_dir" -PathType leaf)
{
$new_dir = Split-Path -Parent $new_dir
}
$new_dir = Resolve-Path $new_dir
$path_list += $new_dir
}
# Load settings file
$settings_file = "$PSScriptRoot/Settings.json"
$json = Get-Content $settings_file | ConvertFrom-Json
# Display content of "Search Directorys"
Write-Host "Includes:"
foreach ($item in $json.Includes)
{
Write-Host " $item"
}
# Add and display new directories
foreach ($item in $path_list)
{
if ($json.Includes -notcontains $item)
{
Write-Host "+ $item"
$json.Includes += "$item"
}
}
# Store modified Settings file
$json | ConvertTo-Json -Compress -depth 32| set-content $settings_file
# Start VDF
Start-Process -FilePath "$PSScriptRoot\VDF.GUI.exe"
Very good. Thank you for taking the time to write.
Environment
Describe desired feature
Commandline parameter to populate "Search Directories" list:
What issue does it solve?