I am trying to get a setup where I can right click on files and select a context command. I've put the .bat into the registry and everything like that. My issue is that I want to remove the spaces of the file I right clicked on, because the command line of the other program I am using seems to be incompatible with spaces in the file names.
@echo off
SET rn="%1"
ren %rn% % rn: =%
SET input="%1"
SET outname="%~d1%~p1%~n1signed.pdf"
cd "C:\Program Files (x86)\PDFtk Server\bin"
pdftk %input: =% background Z:\Documents\docsig.pdf output %outname: =%
pause
I'm very new at batching. Maybe the solution is simple? The issue is that I do not want the batch to rename multiple files at a time. Everything I've found that works does the whole directory at once.
@echo off
setlocal enabledelayedexpansion
for %%a in (* *) do (
set file=%%a
ren "!file!" "!file: =!"
)
Above is one such example. Is there a way to tweak this to change just the file I right clicked on?
Thank you in advance!
ren %rn% % rn: =%this is incorrect, because % rn% will find a variable with space in the name, which doesn't exist