# Useful Scripts to Copy and Paste

**Script 1:** Batch convert \[.svg / .pdf / .eps / .emf / .wmf] files to \[.eps / .pdf / .png / .svg]\
Very useful for writing papers and standardizing file types\
<https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11>

```
:: From https://gist.github.com/JohannesDeml/779b29128cdd7f216ab5000466404f11
:: Convert vector file formats in the current folder and their subsfolders
:: The variables in the beginning can be changed to your needs
:: Tested for Inkscape 1.0 - 1.3

@echo off
setlocal ENABLEDELAYEDEXPANSION

:: Define supported input file extensions
set validInput=svg pdf eps emf wmf ps ai cdr

:: Define supported output file extensions
:: All supported extnesions: [.dxf, .emf, .eps, .fxg, .gpl, .hpgl, .html, .jpg, .odg, .pdf, .png, .pov, .ps, .sif, .svg, .svgz, .tar, .tex, .tiff, .webp, .wmf, .xaml, .zip]
set validOutput=svg png tiff jpg webp pdf eps emf wmf ps cdr

:: Define relative output folder, if you want to write to the same folder set the var to an empty string
set relativeOutputFolder=out\

:: Possible paths to check for the installation
set "inkscapePaths[1]=C:\Program Files\Inkscape\bin\inkscape.com"
set "inkscapePaths[2]=C:\Program Files\Inkscape\bin\inkscape.exe"
set "inkscapePaths[3]=C:\Program Files\Inkscape\inkscape.com"
set "inkscapePaths[4]=C:\Program Files (x86)\Inkscape\bin\inkscape.com"
set "inkscapePaths[5]=C:\Program Files (x86)\Inkscape\bin\inkscape.exe"
set "inkscapePaths[6]=C:\Program Files (x86)\Inkscape\inkscape.com"
set "inkscapePaths[7]=%UserProfile%\scoop\apps\inkscape\current\bin\inkscape.exe"

set "inkscapePath="
set /a "pathIndex=1"

:: Find the inkscape installation path
:inkscapepath_loop_start
if defined inkscapePaths[%pathIndex%] (
	set "currentPath=!inkscapePaths[%pathIndex%]!"
	if exist "!currentPath!" (
		:: found installation path
		set "inkscapePath=!currentPath!"
		goto :inkscapepath_loop_end
	)
	set /a "pathIndex+=1"
	goto :inkscapepath_loop_start
) else (
	echo Can't find Inkscape installation, aborting.
    goto end
)
:inkscapepath_loop_end

:: Set the path to allow for spaces without any needed additional quotes
set inkscapePath="%inkscapePath%"

set validInputString=
(for %%a in (%validInput%) do ( 
   set validInputString=!validInputString!, %%a
))
:: Remove the leading comma
set validInputString=%validInputString:~2%

set validOutputString=
(for %%a in (%validOutput%) do ( 
   set validOutputString=!validOutputString!, %%a
))
:: Remove the leading comma
set validOutputString=%validOutputString:~2%

:: If this can't be run, then the version is an older one
FOR /F "tokens=* USEBACKQ" %%g IN (`%inkscapePath% --version`) do (SET "inkscapeVersion=%%g")
if "%inkscapeVersion%" EQU "" (
	set inkscapeVersion=0.x
	set /a inkscapeMajorVersion=0
) else (
set /a inkscapeMajorVersion=%inkscapeVersion:~9,1%
)

echo.
echo This script allows you to convert all files in this folder from one file type to another
echo Running with %inkscapeVersion% from %inkscapePath%
echo (type q to quit at any question)
echo.

set valid=0
echo Allowed file types for source: %validInputString%
:whileInNotCorrect
	set /p sourceType=What file type do you want to use as a source?
	if "%sourceType%" EQU "q" exit /b
	for %%a in (%validInput%) do (
	  if "%%a"=="%sourceType%" (
		set valid=1
		goto inSet
	  )
	)
	if %valid% EQU 0 (
		echo Invalid input! Please use one of the following: %validInputString%
		goto :whileInNotCorrect
	)

:inSet
echo.

set valid=0
echo Allowed file types for output: %validOutputString%
:whileOutNotCorrect
	set /p outputType=What file type do you want to convert to? 
	if "%outputType%" EQU "q" exit /b
	for %%a in (%validOutput%) do (
	  if "%%a"=="%outputType%" (
		set valid=1
		goto outSet
	  )
	)
	if %valid% EQU 0 (
		echo Invalid input! Please use one of the following: %validOutputString%
		goto :whileOutNotCorrect
	)

:outSet

if "%outputType%" EQU "%sourceType%" (
	echo Input and Output are the same, no point in doing anything. Exiting...
	exit /b
)

echo.

:: Set DPI for exported file
:whileNotValidDpiNumber
	set /p dpi=With what dpi should it be exported (e.g. 300)? 
	if "%dpi%" EQU "q" exit /b
	IF %dpi% NEQ +%dpi% (
		echo Invalid input! Please input an actual number.
		goto :whilenotValidDpiNumber
	)
echo.

:: count how many files we need to convert before converting!
set /a total=0
for /R %%i in (*.%sourceType%) do (	set /a total=total+1 )
echo Found %total% file(s) of type *.%sourceType% in the current folder (%~dp0)

echo.

:: Create output folder if it is set and does not exist
if not "!relativeOutputFolder!"=="" (
	if not exist "!relativeOutputFolder!" mkdir "!relativeOutputFolder!"
)

set /a count=0
:: Running through all files found with the defined ending
if %inkscapeMajorVersion% NEQ 0 (
	:: Inkscape 1.0 and newer
	for /R %%i in (*.%sourceType%) do (
		set /a count=count+1

        echo %%i -^> %%~di%%~pi!relativeOutputFolder!%%~ni.%outputType% ^[!count!/%total%^]
        %inkscapePath% --export-filename="%%~di%%~pi!relativeOutputFolder!%%~ni.%outputType%" --export-dpi=%dpi% "%%i"
	)
)

echo.
echo %count% file(s) converted from %sourceType% to %outputType%! (Saved in out folder)
echo.

:end
pause
```

**Script 2:** Export When2Meet to a CSV\
Open up the developer console in your browser and run the linked code. You can then paste the data into excel and go from there\
<https://gist.github.com/aculich/b60c9e79e7a1113393127c51701f2d7b>

```
function getCSV() {
  result = "Time," + PeopleNames.join(",")+"\n"; 
  for(let i = 0; i < AvailableAtSlot.length; i++) {
      let slot = $x(`string(//div[@id="GroupTime${TimeOfSlot[i]}"]/@onmouseover)`);
      slot = slot.match(/.*"(.*)".*/)[1];
      result += slot + ",";
      result += PeopleIDs.map(id => AvailableAtSlot[i].includes(id) ? 1 : 0).join(",");
      result+= "\n";
  }
  console.log(result);
  return result;
}
copy(getCSV()); // automatically copy results to clipboard
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://swissler-innovative-robotics-lab.gitbook.io/lab-onboarding/software/programming/useful-scripts-to-copy-and-paste.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
