Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
doscode
- Posts: 175
- Joined: 15 Feb 2012 14:02
#1
Post
by doscode » 05 Jun 2012 04:47
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:
and ends with
the files are not ordered correctly (having diacritics inside)
I want to get just list of files (no extension) and write it into file.
-
dbenham
- Expert
- Posts: 2461
- Joined: 12 Feb 2011 21:02
- Location: United States (east coast)
#2
Post
by dbenham » 05 Jun 2012 05:11
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
-
doscode
- Posts: 175
- Joined: 15 Feb 2012 14:02
#3
Post
by doscode » 05 Jun 2012 05:36
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
-
Squashman
- Expert
- Posts: 4471
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 05 Jun 2012 06:14
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