Script to copy filename ONLY

28 views
Skip to first unread message

Alexis Ponce

unread,
Nov 12, 2025, 12:24:14 PMNov 12
to OneCommander
Is it possible to have a script to copy a filename?

And another question: what language are the OC scripts written in? Is there a collection to add more?

OneCommander Support

unread,
Nov 13, 2025, 2:01:38 PMNov 13
to OneCommander
You can write script for that using cmd, powershell, or anything else that can take parameters or environment variables (so even python if you have it installed). See the example scripts in scripts folder on how to pass selection or current folder to each. The only collection of scripts is this one created by one of the users. I have not tested all https://github.com/kamekairos/KK-OneCommanderScripts

Alexis Ponce

unread,
Nov 13, 2025, 2:16:24 PMNov 13
to OneCommander
I tried with some that chatgpt helped me with, without success.

# Copiar nombre del archivo (sin extensión) al portapapeles
param(
    [Parameter(Mandatory=$true)]
    [string]$RutaArchivo
)

# Obtener solo el nombre del archivo sin extensión
$nombre = [System.IO.Path]::GetFileNameWithoutExtension($RutaArchivo)

# Copiar al portapapeles
Set-Clipboard -Value $nombre

Write-Host "Nombre copiado al portapapeles: $nombre"

teddy

unread,
Dec 3, 2025, 3:54:28 PM (5 days ago) Dec 3
to OneCommander
Short answer: You can use this value in $SelMultiple in your script.

I was looking for a way to pass the selected filename to the script.
After going through some samples in the github repo above I found that the selected file is $SelMultiple

My script is a simple one like this
#CMD
pdfsplit.bat $SelMultiple 1 2

And after selecting the file and clicking the script icon, choosing the right script i get the confirmation dialog like the attached picture showing that the $SelMultiple variable is expanded as expected and shown before running it.

Clicking OK will execute the command as displayed and it works as expected, the filename was passed to my pdfsplit.bat properly.
So you can use this value in $SelMultiple in your script

I could not find a list of built-in variables to be used in OneCommander scripting. Having a list would be helpful, for example after some trial and error i found that $Sel
is for single selection but cannot be used when $SelMultiple is also used in the script.

I found some variables somewhere in other posts in this group too but doesn't work %SELECTED_FILES%? OC_SELECTED_FILES? 
they are not in the windows system environment variables as i tried this, but nothing related to onecommander is listed.
#CMD
set > env_var.txt
REM and this one returned empty
echo %SELECTED_FILES% > temp_files.txt

I hope this helps.
If someone knows an official list, please post the link, it would help a lot.

Screenshot 2025-12-03 165600.png
Reply all
Reply to author
Forward
0 new messages