0

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,

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Tiur
0

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,

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.