Hi, I have a txt file called named.txt Is the

September 15, 2010 at 12:58:29
Specs: Windows 7
Hi, I have a txt file called named.txt Is there a way to create a batch file to read every letters 2 through 7 letters from every line from name.txt and ignore the rest and output it onto a different txt file called name2.txt. i used the dir /B *.png > name.txt and created a txt file with the names of my png.

G2010060sample.png
G2010061sample.png
G2010062sample.png
G2010063sample.png

would like it to create a new batch file that will take those .png names and renamed and output them into a new txt file if possible.

2010060.png
2010061.png
2010062.png
2010063.png


See More: Hi, I have a txt file called named.txt Is the

Report •


#1
September 15, 2010 at 13:42:11
So if im not wrong you want:
bat file to read 2 letters from a line of 7 charracters from file name.txt <output to> name2.txt

bat file to get the data from name.txt and then to rename your png files??

Please explain with a little more detail


Report •

#2
September 15, 2010 at 15:04:31
Sorry for the unclarity.


The bat file will read the from the 2nd letters to the 7th letters out of 14 letters from name.txt. It will disregard the 1st letters and 8-14.

Then it will <output to> name2.txt.

So for example in my name.txt i have

G2010060sample.png
G2010061sample.png
G2010062sample.png
G2010063sample.png

the bat file with read the take the from the 2nd letter which is (2) to the 7th which is (0).
and place them into a new txt to read as:

2010060.png
2010061.png
2010062.png
2010063.png


Report •

#3
September 15, 2010 at 18:58:42
download sed for windows then do this
C:\test>sed -r "s/^.(.......).*/\1.png/" file
2010060.png
2010061.png
2010062.png
2010063.png

GNU win32 packages | Gawk


Report •

Related Solutions

#4
September 16, 2010 at 07:45:58
If the purpose is to rename files, no need to create txt files.


===================================
@echo off & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in ('dir/b *.png') do (
set N=%%~Na
set N=!N:~1,6!
ren %%a !N!%%~Xa
)


=====================================
Helping others achieve escape felicity

M2


Report •

#5
September 16, 2010 at 09:22:26
works great! thanks you but it actually rename the file which i don't want. I included a
dir /B *.png > out.txt after ren %%a !N!%%~Xa. This way i can see the file renamed in a txt file. Is there a way to stop the file from actually being renamed in the .png folder.?


Report •

#6
September 16, 2010 at 09:42:13
change this:

ren %%a !N!%%~Xa

to this:

echo ren %%a !N!%%~Xa


=====================================
Helping others achieve escape felicity

M2


Report •

#7
September 16, 2010 at 14:20:24
tried it but it gives me the original back.

G2010060sample.png
G2010061sample.png
G2010062sample.png
G2010063sample.png


Report •


Ask Question