Hi,

I have a batch that has 1 input parameter.
Parameter value can be like this: Test.xls

I want to change the text inside this parameter, so that it changes from Test.xls to Test.ppt or whatever file extension.

Does anyone know how to change the last 3 chars in a string in a batch file?

I know that this could be fixed by using two parameters, like 'Test' and 'xls', but this is not an option since in my original file im already using 9 parameters...

I really hope someone can help me with this :)

Here is some example content in my batch file (FILENAME = Test.xls):
@echo off
SET FILENAME=%1
REM Batch should now create and save 4 new variables,
REM which contains the whole filename, but with other parameters.


Thanks,

Hi,

I have a batch that has 1 input parameter.
Parameter value can be like this: Test.xls

I want to change the text inside this parameter, so that it changes from Test.xls to Test.ppt or whatever file extension.

Does anyone know how to change the last 3 chars in a string in a batch file?

I know that this could be fixed by using two parameters, like 'Test' and 'xls', but this is not an option since in my original file im already using 9 parameters...

I really hope someone can help me with this :)

Here is some example content in my batch file (FILENAME = Test.xls):
@echo off
SET FILENAME=%1
REM Batch should now create and save 4 new variables,
REM which contains the whole filename, but with other parameters.


Thanks,

Hi, i have figured out a way to do this:
FOR /F "usebackq" %%I IN ('%1') DO set var1=%%~nI.PPT

Thanks,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.