Batch Lines not showing up correctly - windows-7

Trying to add some lines ╔═╬ to my batch files. The issue I am having is that they do not show up properly in CMD.
I am using Windows 7 Professional.

Change your codepage, maybe? In your bat file, issue a chcp 437

I had to use CHCP 65001 to get the characters to work correctly for me.

I've seen this one a few times... Open the file in Notepad and Save as ... make sure to change the Encoding to ANSI ... (right next to the Save button)

Related

In Windows 10 how do I rename a file to a filename that includes a character with an umlaut?

I'm on Win10 and I have a .bat file to rename a bunch of files. Some of the entries need to be renamed to a non-English name, e.g.
RENAME "MyFile1.txt" "Eisenhüttenstadt.txt"
However, when I run this, the 'ü' comes out as something else, other characters with an umlaut also are replaced by different characters.
I've tried saving the .bat file in Notepad with Unicode and UTF-8 encoding but then Windows doesn't recognise the command when I try to run it.
I've read this and other similar issues but not found a solution, surely it's simple when you know how?
Any suggestions?
The default code page in the console is 437(USA) or 850(Europe), which does not support characters with umlaut, so you must change this to 1252(West European Latin). So, use Chcp command in the beginning of your batch file to change it, like this:
Chcp 1252
Example:
image via http://www.pctipp.ch/tipps-tricks/kummerkasten/windows-7/artikel/windows-7-umlaute-in-batch-dateien-55616/
Sources:http://ss64.com/nt/chcp.html , http://www.pctipp.ch/tipps-tricks/kummerkasten/windows-7/artikel/windows-7-umlaute-in-batch-dateien-55616/ (The article says for Windows 7 but this applies for Windows 10 too)

CMD: '■m' is not recognized as an internal or external command

I am trying to get a batch file to work. Whenever I attempt to run a .bat the command line returns '■m' is not recognized... error, where "m" is the first letter of the file. For example:
md c:\testsource
md c:\testbackup
Returns
C:>"C:\Users\Michael\Dropbox\Documents\Research\Media\Method Guide\Program\test
.bat"
C:>■m
'■m' is not recognized as an internal or external command,
operable program or batch file.
Things I have tried:
Changing Path variables, rebooting, etc.
Changing file directory (i.e. run from C:)
Running example files from web (like above) to check for syntax errors.
Thanks
What text editor are you writing this in? It seems like your text editor may save the file as UTF-16 encoded text, which cmd.exe can't handle. Try setting the "coding"/"file encoding" to "ANSI" when saving the file.
This results in the first byte being a byte-order-mark (telling other editors how to process the file), and cmd.exe can't deal with this.
In addition to the approved answer I would add the case where is a PowerShell command the one that creates the file... PowerShell comes by default with the UTF-16 encoding.
To solve your problem then, force the file encoding lie this: | out-file foo.txt -encoding utf8
Answer based on this other answer.
In windows 10 I had the same issue.
Changing the character set to UTF-8 made it worse.
It worked correctly when I selected Encoding as UTF-8-NO BOM.

"edit" not a valid command in cmd.exe?

I'm trying to create a .cfg file for bcc32 compiler and I'm following the instructions. I have installed correctly and placed an environment path as instructed but when I type "edit bcc32.cfg" into the command prompt it says that edit isn't a valid command? What am I supposed to do?
You could also create a .bat file, edit.bat, to replace the 16-bit edit program (removed because x64 windows flavors won't run it) which would launch your favorite editor.
#echo off
notepad %1
#echo on
This is what I wound up doing as a simple patch so I could carry on the way I always had for the most part. Just type:
edit myfile.ext
in the command prompt to use it.
Note: notepad is not my favorite editor - this is just an example that will work with stock windows.
Note 2: #echo off and #echo on are shown for clarity. You may also shorten this by omitting the echo statements and simply placing the # before the command to be silenced.
#notepad %1
I just use notepad (since they took out the edit command) from the command window like so:
C:\Borland\BCC55\bin> notepad bcc32.cfg
The file will open in notepad for editing. When you've finished editing the file, save it and you're done.
I have found this works for seeing in-window text of a complete file, on a 64bit machine. Once your path is set in cmd prompt, type the word type... followed by "filename" do you see how I used the quotes around the filename only!
type "filename"
You type it just like this (changing filename for your files name) and you will be able to see the entire file text in the cmd window. Not sure how to edit from here on but maybe someone can figure it out from here and tell me.
Assuming you're using Windows 7 (where edit.exe and edlin.exe have been removed):
Use powershell.exe instead of cmd - thereby edit will be available via command line.
Take a look at: http://en.wikipedia.org/wiki/Windows_PowerShell
simple answer....
if your using an old version of windows (xp e.t.c...) you would be able to use edit
but since your using new version of windows, Microsoft has updated and removed the commands that they think are not relevant e.g.. (msg, edit) depending if its a bit32 bit64 or bit82...

Vim. Troubles with encoding on file saved in windows

I have ��� chars after each time I save file in windows for some folders. And for some other folders - all is fine. I can't find difference between folders where everything is fine and folders where files saving with bad endings. So I have to run dos2unix in my linux virtual machine on modified files every time. Since these files is javascript - it's very annoying!
Help me, where to dig? How to avoid appearing of ��� chars at the end of file?
:set fileencoding=utf-8 does not help.
Usually vim has for dos files - [dos] label at the bottom of buffer window - in my case all is fine, and no [dos] label there.
This looks more like a file format problem than encoding. I recommend adding this to your ~/_vimrc:
set fileformat=unix
set fileformats=unix,dos
set nobinary
You can find more details in :help fileformat

Windows batch: Unicode parameters for (robo) copy command

I need to copy multiple files in a single batch file. The files have Unicode names that map to different codepages.
Example:
set ArabicFile=ڊڌڵڲڛشس
set CyrillicFile=щЖЛдЉи
set GermanFile=Bücher
copy %ArabicFile% SomePlaceElse
copy %CyrillicFile% SomePlaceElse
copy %GermanFile% SomePlaceElse
Problem: Batch files cannot be Unicode.
Question: How can I write the Unicode file names to the batch file so that the copy command recognizes them?
Notes:
I do not care how the file names are displayed.
Actually the batch file does much more than just copy these files, I just simplified the description to make the problem clearer.
Correct batch file:
With Arnout's answer I modified my batch file as follows. It now works correctly without requiring a font change (which would be messy, as Arnout commented).
#echo off
chcp 65001
set ArabicFolder=ڊڌڵڲڛشس
set CyrillicFolder=щЖЛдЉи
set GermanFolder=Bücher
robocopy /e d:\temp\test\%ArabicFolder% d:\temp\test2\%ArabicFolder% /log:copy.log
robocopy /e d:\temp\test\%CyrillicFolder% d:\temp\test2\%CyrillicFolder% /log+:copy.log
robocopy /e d:\temp\test\%GermanFolder% d:\temp\test2\%GermanFolder% /log+:copy.log
If
I add CHCP 65001 as the first line of your batch file,
save the file as UTF-8 without BOM, and
set my console font to something else than "Raster Fonts" (on my Win7 box I can choose Consolas or Lucida Console),
it works. Simple, no? :-)
(The font change is actually not necessary, provided you're not writing non-ASCII output to the console.)
I'm not certain, but I think the short (8.3) filename will be ASCII, so you could refer to it that way? You can find out the short filename with dir /X .
I want to create a batch file (e.g. RunThis.bat) which creates directories of names that can be Russians or others.
Example:
When DOS Windows is open with prompt:
D:\>md "Russia - Шпионка"
This work in command like and the name appear correctly.
But if I try that using Notepad and save in ANSII, I can’t.
So if I use again Notepad and save in UTF-8, it will work but with garbage characters.
RunThis.bat (Notepad save UTF-8), give garbage characters.
chcp 65001
set fn14="Russia - Шпионка"
md %fn14%
The problem with notepad it uses UTF-8 with BOM.
To save the .bat using UTF-8 without BOM we must use editor like Notepad++.
RunThis.bat (Notepad++ save UTF-8 – no BOM)
chcp 65001
set fn14="Russia - Шпионка"
md %fn14%
This time its work perfectly when we run “RunThis.bat” directly from explorer.exe

Resources