4

I am using this in my program

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

The filename is in %%I.

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

Is this possible in DOS or Cmd.exe?

6

http://www.dostips.com/DtTipsStringManipulation.php

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

I think.. geez, its been a while!

| improve this answer | |
1
@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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.