Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using this in my program

for %%I in (*.txt) do (

The filenmae is in %%I.

Now i want to separate the first 2 chracters , next 3 characters , separately.

is it possible in DOS or Cmd.exe

share|improve this question
up vote 5 down vote accepted

set first2=%%I:~0,2% && set next3=%%I:~3,3%

I think.. geez, its been a while!

share|improve this answer
Thanks mate , it worked – Mirage Feb 22 '10 at 6:20
+1 for the web site - cheers. – Umber Ferrule Mar 11 '10 at 9:31

@echo off setlocal enabledelayedexpansion for %%a in (*.mp3) do ( set oldName=%%a Set newName=!oldName:~3! Ren "!oldName!" "!newName!" ) exit

_Strip 3.cmd is a good name to save this to. Works for me. I have it (.mp3) to only work with mp3 files ... you can change it to (.*)

Change the ~3! to another number if you want to...... ~4! will truncate the first 4 characters of the file name.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .