DosTips.com

A Forum all about DOS Batch
It is currently 02 Dec 2016 18:21

All times are UTC-06:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 05 Jun 2012 04:47 
Offline

Joined: 15 Feb 2012 14:02
Posts: 174
It should print all xml files
Code: Select all
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: Select all
   'dir

and ends with
Code: Select all
   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.


Top
   
PostPosted: 05 Jun 2012 05:11 
Offline
Expert

Joined: 12 Feb 2011 21:02
Posts: 1778
Location: United States (east coast)
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


Top
   
PostPosted: 05 Jun 2012 05:36 
Offline

Joined: 15 Feb 2012 14:02
Posts: 174
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


Top
   
PostPosted: 05 Jun 2012 06:14 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3364
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: Select all
Before1   After1
Before2      After2
Before3         After3
Before4            After4

delims.bat
Code: Select all
@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: Select all
Before1      After1
Before2      After2
Before3      After3
Before4      After4


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: No registered users and 8 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited