1

this is the code of my .bat file:

@echo off
xcopy "C:\Users\Administrator\věc" "C:\věc"  /e /i /h
echo Done
pause

However it says:File not found - výc. See ě char changed into ý

Why is it so? Thanks

Edit: I'm trying to copy directory, not a file

2
  • I don't know how you are getting any results at all. I copied your text into notepad and hit save. There is a option for enocding. If you select ANSI, the ě becomes e. If you select Unicode or UTF-8, cmd throws garbage. eg:' C:\Users\ben>∩╗┐@echo off '∩╗┐@echo' is not recognized as an internal or external command, operable program or batch file." etc, etc.
    – Ben L
    May 14, 2013 at 16:08
  • well in my machine it becomes ý... It may be because of some local settings? I don't know, however it doesn't really matter whether it's ý or e
    – simPod
    May 14, 2013 at 20:14

4 Answers 4

1

One option is to use a wildcard character for your locations:

xcopy "C:\Users\Administrator\v*c" "C:\v*c"  /e /i /h

It may not be ideal, but it'll work under a few conditioms.

  1. No other folders could match the expression 'v (any characters) c' (such as vehdgthc), that is true in the src and dest.

  2. The dir on c already exists for the dest.

4
  • Your answer is great as it clearly states any short comings too. +1
    – Dave
    May 14, 2013 at 14:46
  • Well, now it does this: File not found - v*c
    – simPod
    May 14, 2013 at 14:49
  • This is odd - it should be looking for a folder. It appears that although using the wildcard, the XCOPY is reading the special character so the same issue persists
    – Dave
    May 14, 2013 at 14:50
  • Try not using " " with wild characters. It's been a while since I don't use Windows but I guess it has the same effect of ' ' in most operating systems and programming languages.
    – Alex
    May 14, 2013 at 15:28
1

The problem is in the interpretation of the bat file. I generate commands which work in command line mode, but don't work in the bat file. It is not Ansi or unicodes fault since I can copy and paste into the command interpreter, and it works just fine. Unfortunately the rules for bat file interpretation don't seem to be clearly documented.

1
  • It isn't clear whether you're explaining definitively why this won't work, speculating why this won't work, or just making general observations. The first case would qualify as an answer if you can clarify it and make it more definitive. The other two cases don't meet the definition of an answer on SU.
    – fixer1234
    Dec 3, 2014 at 7:06
0

This is due to unicode and more about how the special character is displayed. Unicode characters will display differently in Notepad and Wordpad for example.

In your case, it appears this special character is confusing the XCopy command and making it think it is a file, and not a folder.

If it is an option, change it to an e and then try it again. I appreciate it's not ideal as you're having to create a new word but this should work. If it does, then you know the issue is with the character, if not then obviously you'll need to investigate further.

Edit

I can't test this, but you could try Robocopy (not sure what OS you're using)

robocopy" C:\Users\Administrator\věc" "C:\věc"

EDIT 2

Or, the issue is, your machine is not showing you file extensions, so you think your file is věc . It is not likely! Your file should be name dot extensions

EG

věc.txt or věc.pdf
7
  • Well, I don't want to change the name of my file but it's the problem with that character, for sure. Using wild card is elegant workaround but it's still just workaround, I'd prefer clean solution though. Thanks for your responses anyway!
    – simPod
    May 14, 2013 at 14:42
  • @simPod, can you try using Robocopy (if applicable) and see if the issue persists?
    – Dave
    May 14, 2013 at 14:48
  • Using Robocopy: ERROR : Invalid Parameter #1 : "C:\Users\Administrator\v*c"
    – simPod
    May 14, 2013 at 14:51
  • @simPod - see my Edit 2
    – Dave
    May 14, 2013 at 14:52
  • Saw, see my Edit ;)
    – simPod
    May 14, 2013 at 14:53
0

In your editor, make sure you use Ansi encoding, not OEM.

4
  • I'm using ANSI, it's notepad
    – simPod
    May 14, 2013 at 15:05
  • What default ANSI encoding do you have set in Windows? May 15, 2013 at 6:13
  • Where can i find out?
    – simPod
    May 17, 2013 at 16:24
  • Depends on your version of Windows. For instance on XP, it's Control Panel > Regional and Language Options > Advanced tab > Language for non-Unicode programs May 20, 2013 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .