atxman
asked on
DOS string replace and remove character at end
I have a batch script that accepts as the argument a directory. I need to first check to see if the last character of the string ends with \ and remove it, if it does. I also need to replace all \ with /. I attempted a solution for this second part but it paritally works. It will remove the data before the : and replace all \ with / but I do not need the data prior to the : removed.
Below is my batch script:
Below is my batch script:
@echo off
IF %1=="" GOTO DEFAULTDIR;
SET dir=%1%
GOTO MAINPROCESS;
:DEFAULTDIR
SET dir=%~p0
#replacing \ with /
set dir=%dir:\=/%
ECHO Using %dir% as parent path
:MAINPROCESS
set jardir=%dir%jars
echo Jar directory is %jardir%
echo Completed
:DONE
ECHO DONE
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the response
How about separating it? Instead of
SET dir=%~p0
set dir=%dir:\=/%
Do...
SET dir_tmp=%~p0
set dir=%dir_tmp:\=/%