Accent lettres are lost / FOR loop to make multiple folders
Moderator: DosItHelp
Accent lettres are lost / FOR loop to make multiple folders
Hello,
A.
The accent letters are lost (transformed: è->Š) using this BATCH file
http://dostips.cmdtips.com/DtCodeBatchF ... c145951134
on a French MS Win XP (no SP) system.
How to keep the accent letters ?
We get the accent in a DOS session, I mean the accents appear.
B.
FOR /L %%I in (1,2,5) DO (
SET /A v=1+%%I
MD page%%I_%v%
)
This script should create 3 folders named page1_2, page3_4, page5_6
but it creates page1_, page3_, page5_
Why the variable v is lost ?
Thanks.
A.
The accent letters are lost (transformed: è->Š) using this BATCH file
http://dostips.cmdtips.com/DtCodeBatchF ... c145951134
on a French MS Win XP (no SP) system.
How to keep the accent letters ?
We get the accent in a DOS session, I mean the accents appear.
B.
FOR /L %%I in (1,2,5) DO (
SET /A v=1+%%I
MD page%%I_%v%
)
This script should create 3 folders named page1_2, page3_4, page5_6
but it creates page1_, page3_, page5_
Why the variable v is lost ?
Thanks.
budhax,
The easy one first:
B)
Your problem is that the command interpreter resolves %v% only once right before executing the for-loop.
To fix this you can either use DELAYEDEXPANSION or run MD in a new batch file context.
Use DELAYEDEXPANSION:
Use new batch file context:
DOS IT HELP?
I will get back to you on issue A.
The easy one first:
B)
Your problem is that the command interpreter resolves %v% only once right before executing the for-loop.
To fix this you can either use DELAYEDEXPANSION or run MD in a new batch file context.
Use DELAYEDEXPANSION:
Code: Select all
setlocal ENABLEDELAYEDEXPANSION
FOR /L %%I in (1,2,5) DO (
SET /A v=1+%%I
call MD page%%I_!v!
)
Use new batch file context:
Code: Select all
FOR /L %%I in (1,2,5) DO (
SET /A v=1+%%I
call MD page%%I_%%v%%
)
DOS IT HELP?
I will get back to you on issue A.
budhax,
Now to your tough one: A
Unfortunately I only have an English OS available.
I tried A2 as described below using the accent letter you provided by copying the letter from your forum post into the help.bat. It worked ok, both è and Š appeared properly in the HTML.
Here is something to try out for you.
A1)
-From a command line run: cmd /U
This opens a new batch file context having the output of internal commands to a pipe or file to be Unicode.
-Now run DosCommandRef.bat from that command line.
-Review the accent letters in the output and let me know.
If the accent letters are still transformed then proceed with A2:
A2)
- Download the latest version of DosCommandRef.bat (Important!) and help.bat into same directory:
http://www.dostips.com/DosCommandRef.bat
http://www.dostips.com/help.bat
-Optionally edit help.bat with a text editor and add some more accent letters.
-Run: DosCommandRef.bat
-Review the accent letters in the html output and let me know.
help.bat will emulate the WinXP help command to allow better testing.
In case you modified the help.bat, please post it's content with your reply.
Remove or rename help.bat in order to have DosCommandRef.bat use regular WinXP help information.
Thanks in advance ...
Now to your tough one: A
Unfortunately I only have an English OS available.
I tried A2 as described below using the accent letter you provided by copying the letter from your forum post into the help.bat. It worked ok, both è and Š appeared properly in the HTML.
Here is something to try out for you.
A1)
-From a command line run: cmd /U
This opens a new batch file context having the output of internal commands to a pipe or file to be Unicode.
-Now run DosCommandRef.bat from that command line.
-Review the accent letters in the output and let me know.
If the accent letters are still transformed then proceed with A2:
A2)
- Download the latest version of DosCommandRef.bat (Important!) and help.bat into same directory:
http://www.dostips.com/DosCommandRef.bat
http://www.dostips.com/help.bat
-Optionally edit help.bat with a text editor and add some more accent letters.
-Run: DosCommandRef.bat
-Review the accent letters in the html output and let me know.
help.bat will emulate the WinXP help command to allow better testing.
In case you modified the help.bat, please post it's content with your reply.
Remove or rename help.bat in order to have DosCommandRef.bat use regular WinXP help information.
Thanks in advance ...
not concluant result
B. Thank you very much, it helps a lot.
A1.
Start menu > run > cmd /U
DosCommandRef.bat
and I got:
help.bat file:
so, è is transformed to Þ
and Š is transformed to è
A2.
I removed help.bat
then run the same line: DosCommandRef.bat
and I got:
so, accent letters are still transformed
Output exemple, from the DOS window on a French MS Windows system:
Start menu > cmd > help assoc
[/code]
A1.
Start menu > run > cmd /U
DosCommandRef.bat
and I got:
DOS command reference
Windows Version : Microsoft Windows XP [version 5.1.2600]
Document Source : http://dostips.cmdtips.com/DosCommandRef.php
Created by : DosCommandRef.bat
Test1 Test2
DOS Batch Source Script that created this Document
TOPTest1
This is Test1.
Here some accent letters Þ - è. Review this line in HTML page.
TOPTest2
This is Test2.
Here some accent letters Þ - è. Review this line in HTML page.
help.bat file:
Code: Select all
@ECHO OFF
REM -- Source dostips.com, provided AS-IS, no warranty what so ever.
REM -- This batch fakes out the help command for testing of the DosCommandRef.bat.
if "%~1"=="" (
echo.Test1
echo.Test2
GOTO:EOF
)
rem Below some fake help text. Add some accent letters for testing:
echo.This is %~1.
echo.Here some accent letters è - Š. Review this line in HTML page.
echo.
so, è is transformed to Þ
and Š is transformed to è
A2.
I removed help.bat
then run the same line: DosCommandRef.bat
and I got:
DOS command reference
Windows Version : Microsoft Windows XP [version 5.1.2600]
Document Source : http://dostips.cmdtips.com/DosCommandRef.php
Created by : DosCommandRef.bat
Pour ASSOC AT ATTRIB BREAK CACLS CALL CD CHCP CHDIR CHKDSK CHKNTFS CLS CMD COLOR COMP COMPACT CONVERT COPY DATE DEL DIR DISKCOMP DISKCOPY DOSKEY ECHO ENDLOCAL ERASE EXIT FC FIND FINDSTR FOR FORMAT FTYPE GOTO GRAFTABL HELP IF LABEL MD MKDIR MODE MORE MOVE PATH PAUSE POPD PRINT PROMPT PUSHD RD RECOVER REM REN RENAME REPLACE RMDIR SET SETLOCAL SHIFT SORT SUBST START TIME TITLE TREE TYPE VER VERIFY VOL XCOPY
DOS Batch Source Script that created this Document
TOPPour
Cette commande n'est pas prise en charge par l'utilitaire d'aide.
Essayez "x /?".
TOPASSOC
Affiche ou modifie les associations des extensions de fichiers
ASSOC [.ext[=[Type du fichier]]]
.ext Sp‚cifie l'extension de fichier avec laquelle associer le type
Type_de_fichier Sp‚cifie le type de fichier … associer avec l'extension
Entrez ASSOC sans paramŠtres pour afficher les associations actuelles du fichier.
Si ASSOC est appel‚ avec uniquement une extension de fichier, il affiche
l'association de fichier actuelle pour cette extension. Sp‚cifiez nothing pour
le type de fichier et la commande supprimera l'association pour cette extension.
so, accent letters are still transformed
Output exemple, from the DOS window on a French MS Windows system:
Start menu > cmd > help assoc
C:\>help ASSOC
Affiche ou modifie les associations des extensions de fichiers
ASSOC [.ext[=[Type du fichier]]]
.ext Spécifie l'extension de fichier avec laquelle associer le type
Type_de_fichier Spécifie le type de fichier à associer avec l'extension
Entrez ASSOC sans paramètres pour afficher les associations actuelles du fichier
.
Si ASSOC est appelé avec uniquement une extension de fichier, il affiche
l'association de fichier actuelle pour cette extension. Spécifiez nothing pour
le type de fichier et la commande supprimera l'association pour cette extension.
[/code]
budhax,
Thanks for getting back with the results. This surly is strange
After modyfying help.bat to:
I get the following correct output:
This may be related to the code page setting.
Here are two thinkgs to try for you:
A3)
From a command prompt run:
MODE CON CP
Here is what I get:
A4)
From a command prompt run:
for %a in (Spécifie paramètres appelé) do @echo.'%a'
Here is what I get:
Let me know.
Thanks for getting back with the results. This surly is strange
After modyfying help.bat to:
Code: Select all
@ECHO OFF
REM -- Source dostips.com, provided AS-IS, no warranty what so ever.
REM -- This batch fakes out the help command for testing of the DosCommandRef.bat.
if "%~1"=="" (
echo.Test1
GOTO:EOF
)
rem Below some fake help text. Add some accent letters for testing:
echo.This is %~1.
echo.Affiche ou modifie les associations des extensions de fichiers
echo.
echo.ASSOC [.ext[=[Type du fichier]]]
echo.
echo..ext Spécifie l'extension de fichier avec laquelle associer le type
echo.Type_de_fichier Spécifie le type de fichier à associer avec l'extension
echo.
echo.Entrez ASSOC sans paramètres pour afficher les associations actuelles du fichier
echo..
echo.Si ASSOC est appelé avec uniquement une extension de fichier, il affiche
echo.l'association de fichier actuelle pour cette extension. Spécifiez nothing pour
echo.le type de fichier et la commande supprimera l'association pour cette extension.
I get the following correct output:
DOS command reference
Windows Version : Microsoft Windows XP [Version 5.1.2600]
Document Source : http://dostips.cmdtips.com/DosCommandRef.php
Created by : DosCommandRef.bat
Test1
DOS Batch Source Script that created this Document
TOPTest1
This is Test1.
Affiche ou modifie les associations des extensions de fichiers
ASSOC [.ext[=[Type du fichier]]]
.ext Spécifie l'extension de fichier avec laquelle associer le type
Type_de_fichier Spécifie le type de fichier à associer avec l'extension
Entrez ASSOC sans paramètres pour afficher les associations actuelles du fichier
.
Si ASSOC est appelé avec uniquement une extension de fichier, il affiche
l'association de fichier actuelle pour cette extension. Spécifiez nothing pour
le type de fichier et la commande supprimera l'association pour cette extension.
This may be related to the code page setting.
Here are two thinkgs to try for you:
A3)
From a command prompt run:
MODE CON CP
Here is what I get:
Code: Select all
C:\>mode con cp
Status for device CON:
----------------------
Code page: 437
A4)
From a command prompt run:
for %a in (Spécifie paramètres appelé) do @echo.'%a'
Here is what I get:
Code: Select all
C:\>for %a in (Spécifie paramètres appelé) do @echo.'%a'
'Spécifie'
'paramètres'
'appelé'
Let me know.
A3)
I got:
A4)
I got:
Using DosCommandRef.bat and your new help.bat file, I got:
So, ...?
I got:
Code: Select all
C:\>mode con cp
État du périphérique CON:
-------------------------
Page de codes : 850
A4)
I got:
Code: Select all
C:\>for %a in (Spécifie paramètres appelé) do @echo.'%a'
'Spécifie'
'paramètres'
'appelé'
Using DosCommandRef.bat and your new help.bat file, I got:
DOS command reference
Windows Version : Microsoft Windows XP [version 5.1.2600]
Document Source : http://www.dostips.com/DosCommandRef.php
Created by : DosCommandRef.bat
Test1
DOS Batch Source Script that created this Document
TOPTest1
This is Test1.
Affiche ou modifie les associations des extensions de fichiers
ASSOC [.ext[=[Type du fichier]]]
.ext Spécifie l'extension de fichier avec laquelle associer le type
Type_de_fichier Spécifie le type de fichier à associer avec l'extension
Entrez ASSOC sans paramètres pour afficher les associations actuelles du fichier
.
Si ASSOC est appelé avec uniquement une extension de fichier, il affiche
l'association de fichier actuelle pour cette extension. Spécifiez nothing pour
le type de fichier et la commande supprimera l'association pour cette extension.
So, ...?
budhax,
I changed the code settings on my PC to 850 but couldn't reproduce the problem.
It seems that also on your PC the problem cannot be reproduced using the new help.bat file whereas the old help.bat file did show the problem.
Very strange
I'll need to look into this later and keep you posted.
What do you get on your system when typing:
?
I changed the code settings on my PC to 850 but couldn't reproduce the problem.
It seems that also on your PC the problem cannot be reproduced using the new help.bat file whereas the old help.bat file did show the problem.
Very strange
I'll need to look into this later and keep you posted.
What do you get on your system when typing:
Code: Select all
for /f "delims=" %a in ('help assoc') do @echo.%a
?