Hi.
The programmer here at work made a script where we can right click a video file and have it converted to some other format.
The procedure right now is to have no spaces in the filename.
I want to change that, even though I heard it was complicated.
Here's what I was given.
set fileonly=%~n1
set filename=%~dpn1
set filedir=%~dp1
Now I am only at the beginning of my batch script lessons, but I thought I could just add one new line at the beginning to take care of matters.
set n1=%n1: =_%
set fileonly=%~n1
set filename=%~dpn1
set filedir=%~dp1
Apparently I don't understand yet what the tilde is doing in his original code, but where am I going wrong?
And is the n1 the assumed result of a right click selection?
I never saw it set as a variable anywhere else...
Thanks for any help
delete spaces from a filename before using it as variable
Moderator: DosItHelp
Re: delete spaces from a filename before using it as variabl
you must add dbl quotes in all commands with file names, if not present:
%~n1 -> "%~n1"
%~dpn1 -> "%~dpn1"
%~dp1 -> "%~dp1"
%~n1 -> "%~n1"
%~dpn1 -> "%~dpn1"
%~dp1 -> "%~dp1"
Re: delete spaces from a filename before using it as variabl
Thx but there is something more mysterious going on with these variables...
It didn't find the file at all...
I'll have to study some more...
It didn't find the file at all...
I'll have to study some more...