delete spaces from a filename before using it as variable
Posted: 10 Nov 2010 11:30
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
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