techee left a comment (geany/geany#4355) > If I have the skills to write something like it, I should have already done > this.
Oh, skills are so 20th century, we don't need those in the age of "AI"! This is a result of the following prompt to Gemini Pro at https://aistudio.google.com: Prompt: Write a Windows bat file that renames an executable so that it removes a substring from it and executes it with the /S parameter. In particular, the original executable name looks like geany-2.1_git_20250706021513_fa323c999_setup.exe and the bat file should rename it to geany.exe and execute it by appending the /S parameter. The script should take into account that everything after the geany- prefix in the original file (except the .exe suffix) can be variable. The bat file should automatically locate such a file in the same directory where the bat file is placed. Also, if geany.exe already exists in the directory, it should be overwritten by the rename. Response: 1. Copy the code below into a new text file. 2. Save the file with a .bat extension (e.g., install_geany.bat). 3. Place this .bat file in the same directory as your Geany setup executable (e.g., geany-2.1_git_..._setup.exe). 4. Double-click the install_geany.bat file to run it. ```bat @ECHO OFF SETLOCAL :: This script finds a Geany installer in the current directory that matches :: the pattern "geany-*.exe", renames it to "geany.exe", and then executes :: it with the /S parameter for a silent installation. ECHO Searching for Geany installer (geany-*.exe)... ECHO. :: Use a FOR loop to find the first file matching the pattern. :: %%F will contain the full filename of the matched file. FOR %%F IN (geany-*.exe) DO ( ECHO Found installer: "%%F" ECHO Renaming it to "geany.exe"... :: Use the MOVE command to rename the file. :: The /Y switch ensures that if geany.exe already exists, it will be :: overwritten without asking for confirmation. MOVE /Y "%%F" "geany.exe" :: Check if the rename was successful before proceeding. IF NOT EXIST "geany.exe" ( ECHO. ECHO ERROR: Failed to rename the file! GOTO End ) ECHO. ECHO Starting silent installation. Please wait... :: Execute the newly named geany.exe with the /S parameter. :: START /WAIT makes the script pause until the installation is complete. START "Geany Installer" /WAIT geany.exe /S ECHO. ECHO Installation process finished. :: We found and processed the file, so we can exit the script. :: GOTO Found jumps past the "Not Found" error message. GOTO Found ) :: This code is only reached if the FOR loop finds no matching files. ECHO. ECHO ERROR: No Geany setup file matching "geany-*.exe" was found in this directory. :Found :: This label is reached after a successful run. :End :: Pause so the user can read the output before the window closes. ECHO. PAUSE ENDLOCAL ``` How It Works 1. **@ECHO OFF**: Prevents the commands from being displayed in the command prompt window, making the output cleaner. 2. **SETLOCAL ... ENDLOCAL**: Creates a local scope for any environment variable changes, which is good practice. 3. **FOR %%F IN (geany-*.exe) DO (...)**: This is the core of the script. It searches the current directory for any file that starts with geany- and ends with .exe. 4. **MOVE /Y "%%F" "geany.exe"**: When a matching file is found, this command renames it. - %%F is the variable holding the original filename (e.g., geany-2.1_git_..._setup.exe). - /Y is a crucial switch that tells the MOVE command to overwrite the destination file (geany.exe) if it already exists, without prompting you. 5. **START "Geany Installer" /WAIT geany.exe /S**: This command executes the installer. - START runs the program. The "Geany Installer" part is just a title for the command window and is good practice. - /WAIT tells the batch script to pause and wait for the installation process to finish before continuing. - /S is the parameter passed to geany.exe to trigger a silent (unattended) installation. 6. **GOTO Found**: If a file is found and processed, the script jumps to the :Found label, skipping the error message. 7. **Error Message**: If the FOR loop completes without finding any matching files, the script will proceed to the line that displays an error message. 8. **PAUSE**: This command keeps the command window open after the script finishes so you can read the output messages (e.g., "Installation process finished" or the error message). Press any key to close it. --- Poor human again: I've tested this, seems to work fine, it just writes `The system cannot find the drive specified` in its output at some point but I haven't investigated where it comes from. So let's just blindly trust "AI" that the script does the right thing - that's how future will look like anyway. -- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/4355#issuecomment-3053448127 You are receiving this because you are subscribed to this thread. Message ID: <geany/geany/issues/4355/3053448...@github.com>