Computing.Net > Forums > Windows 2000 > cutting from variable in for loop

cutting from variable in for loop

Reply to Message Icon

Original Message
Name: jasdeep_madan
Date: August 31, 2005 at 04:21:52 Pacific
Subject: cutting from variable in for loop
OS: windows 2000
CPU/Ram: 1 gb
Comment:

for %f in ( *.ctl ) do set d1=%f echo %d1~1,2%
this gives the last file number, as i cut the file number positioned at 2nd 3rd place.

I want to cut all the file number stratung from 1 and then my aim is to run sqlplus for everyfile.
But this cuts only last file no and sqlplus for all the times.

while using %f:~1,2% it doesn't give desireed results.
If some escape characters have to be used and where please help me with that. I have tried ^ and "" but to no use.

thanks


Report Offensive Message For Removal

Response Number 1
Name: Mechanix2Go
Date: August 31, 2005 at 05:43:59 Pacific
Subject: cutting from variable in for loop
Reply: (edit)

Do you have "special characters" in the *.ctl filenames?

If so, give examples.

M2
If at first you don't succeed, you're about average.


Report Offensive Follow Up For Removal

Response Number 2
Name: dtech10
Date: September 2, 2005 at 16:20:35 Pacific
Subject: cutting from variable in for loop
Reply: (edit)

Hi
Not quite sure what you want to do, but the code below will echo the 2nd & 3rd character of every filename.

@echo off
setlocal enabledelayedexpansion
for %%f in (*.*) do set d1=%%f & echo !d1:~1,2!


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: cutting from variable in for loop

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software