Solved copy 1st and 2nd character in string and add to the front

October 29, 2014 at 06:02:49
Specs: Windows 7
I have a little experience with batch files, but i wouldn't have a clue how to solve this.
A typical string would be n1010-c_size_batteries.jpg
I want to take the 1st and 2nd character (n1) and add it to the beginning of the original string.
n1n1010-c_size_batteries.jpg
Then i want to place one / at the beginning of the string, after the 1st character and after the 2nd character.
Like this:
/n/1/n1010-c_size_batteries.jpg

This is to enable me to import the correct format and path to the database for product images.
I would be so grateful if someone could help me out.

Many thanks in advance
Andy


See More: copy 1st and 2nd character in string and add to the front

Report •


#1
October 29, 2014 at 09:41:57
✔ Best Answer
First of all the string must be stored in a variable, e.g.

set string=n1010-c_size_batteries.jpg

then using the substrings manipulation modifiers code

set string=/%string:~0,1%/%string:~1,1%/%string%

message edited by IVO


Report •
Related Solutions


Ask Question