View unanswered posts | View active topics It is currently 26 Nov 2014 10:02



Post new topic Reply to topic  [ 4 posts ] 
what's wrong with this loop 
Author Message

Joined: 15 Feb 2012 14:02
Posts: 163
Post what's wrong with this loop
It should print all xml files
Code:
Setlocal EnableDelayedExpansion
@echo off
chcp 1250
FOR /f "delims=" %%x IN (delimiter.ini) DO set TAB=%%x
FOR %%F IN ('dir *.xml /b /o:n') DO (
set file=%%~nF
echo "!file!"
echo %tab%!file!>> files.txt
REM md "!file!"
)
pause


But starts with:
Code:
   'dir

and ends with
Code:
   b
   o:n'

the files are not ordered correctly (having diacritics inside)

I want to get just list of files (no extension) and write it into file.


05 Jun 2012 04:47
Profile
Expert

Joined: 12 Feb 2011 21:02
Posts: 1275
Location: United States (east coast)
Post Re: what's wrong with this loop
You forgot the /F option in your second FOR. You probably also want "eol=: delims=" in case file name contains space(s) or starts with semicolon. You could set EOL to * or ? as well. It just needs to be some character that can never start a Windows file name or path.


Dave Benham


05 Jun 2012 05:11
Profile

Joined: 15 Feb 2012 14:02
Posts: 163
Post Re: what's wrong with this loop
Oh. I it was originaly

FOR %%F IN (*.xml) DO ()

And it worked. So after changing to command and single quotes I did not realized the missing /F

Thanks


05 Jun 2012 05:36
Profile

Joined: 23 Dec 2011 13:59
Posts: 2017
Post Re: what's wrong with this loop
I am still confused by doscode's use of a TAB or his problems using a TAB. Is this a language specific issue with his version of Windows?
Not sure why he is putting the delimiter into a file.

File1.txt
Code:
Before1   After1
Before2      After2
Before3         After3
Before4            After4

delims.bat
Code:
@echo off
set "tab=   "
REM Delims is a tab
(
FOR /F "Tokens=1,2 Delims=   " %%G in ('type File1.txt') do echo %%G%tab%%tab%%%H
)>File2.txt

File2.txt
Code:
Before1      After1
Before2      After2
Before3      After3
Before4      After4


05 Jun 2012 06:14
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: bars143, Bing [Bot], Yahoo [Bot] and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.