cannot copy file with special char in windows

Discuss your Lua playlist, album art and interface scripts.
Misska
New Cone
New Cone
Posts: 4
Joined: 06 Jul 2018 13:43

cannot copy file with special char in windows

Postby Misska » 06 Jul 2018 13:56

Hello,

I am currently working on a lua extension to sort my music.
The tool moves files from a 'unsorted' folder to a defined 'sorted' folder (or to trash).

The tool is working perfectly on Linux, but I getting in trouble with Windows.
my script uses :
os.execute ('cmd mkdir <my_unsorted_folder/album/')
to create the sorted folder

os.execute ('cmd copy /B /Y /V "<my_unsorted_folder/album/track_file>" "<my_sorted_folder/album/my_music_file">')
to place the music file in the created folder

Unfortunately, windows cmd does not consider the special char (like é ç à...) and the command fails. From what I understood, the coding of lua is a kind of UTF8.
however, CMD uses ANSI... so, I am lost.

I have tried to insert chcp commands :
os.execute ('chcp 858 && cmd copy /B /Y /V "<my_unsorted_folder/album/track_file>" "<my_sorted_folder/album/my_music_file">')
but without success...

Cano anyone knows ?
(note, I cannot use powershell)

Kind regards
MissKa

ale5000
Cone that earned his stripes
Cone that earned his stripes
Posts: 125
Joined: 03 Mar 2004 16:12
Operating System: Windows
Contact:

Re: cannot copy file with special char in windows

Postby ale5000 » 06 Jul 2018 17:24

I haven't tried but maybe this:

Code: Select all

os.execute ('chcp 65001 > nul && cmd /u /c "your_command" > log.txt')
If you don't want log then this:

Code: Select all

os.execute ('chcp 65001 > nul && cmd /u /c "your_command" > nul')

Misska
New Cone
New Cone
Posts: 4
Joined: 06 Jul 2018 13:43

Re: cannot copy file with special char in windows

Postby Misska » 07 Jul 2018 16:11

hello,
thank you for your support. I just tried... but it does not work.
here is the part of the code :
part3=string.format('copy /B /Y /V "%s" "%s"', filename, FinalFullPath .. file)
os.execute ('chcp 65001 > nul && cmd /u /c "' .. part3 .. '" > log.txt')
debug_trace(string.format("[Sorting...] +----> (win) " .. part3))
The debug_trace is archiving the message in a file. It shows the good path :
[Sorting...] +----> (win) copy /B /Y /V "K:\Musicologie\music_a_trier\L\La Haine\La Haine\04 La 25ème Image.m4a" "K:\Musicologie\Mytune\41_hiphop_rap_MC\L\La Haine\La Haine\04 La 25ème Image.m4a"
and the log.txt contains:
"Le fichier spécifié est introuvable" ; which means " the requested file cannot be found"

I can copy this "K:\Musicologie\music_a_trier\L\La Haine\La Haine\04 La 25ème Image.m4a" to the cmd and press enter, then it is executed. I really do not understand.

roland1
Blank Cone
Blank Cone
Posts: 44
Joined: 01 May 2014 16:49

Re: cannot copy file with special char in windows

Postby roland1 » 08 Jul 2018 23:06

It depends, but maybe vlc.io

Input/Output
------------
All path for this namespace are expected to be passed as UTF8 strings.

io.mkdir("path", "mode"): Similar to mkdir(2). The mode is passed as a string
to allow for octal representations. This returns a success code (non 0 in
case of failure), and a more specific error code as its 2nd returned value
in case of failure. The error code is to be used with vlc.errno
io.readdir("path"): Lists all files & directories in the provided folder.
io.open("path"[, "mode"]): Similar to lua's io.open. Mode is optional and
defaults to "r". It returns a file object with the following member functions:
.read
.write
.seek
.flush
.close
all of which are used exactly like the lua object returned by io.open
io.unlink("path"): Similar to os.remove. First return value is 0 in case
of success. In case of failure, the 2nd return parameter is an error
code to be compared against vlc.errno values.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: cannot copy file with special char in windows

Postby Jean-Baptiste Kempf » 11 Jul 2018 09:52

but there is no io.copy.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

Misska
New Cone
New Cone
Posts: 4
Joined: 06 Jul 2018 13:43

Re: cannot copy file with special char in windows

Postby Misska » 11 Jul 2018 19:59

It depends, but maybe vlc.io

Input/Output
------------
All path for this namespace are expected to be passed as UTF8 strings.

io.mkdir("path", "mode"): Similar to mkdir(2). The mode is passed as a string
to allow for octal representations. This returns a success code (non 0 in
case of failure), and a more specific error code as its 2nd returned value
in case of failure. The error code is to be used with vlc.errno
io.readdir("path"): Lists all files & directories in the provided folder.
io.open("path"[, "mode"]): Similar to lua's io.open. Mode is optional and
defaults to "r". It returns a file object with the following member functions:
.read
.write
.seek
.flush
.close
all of which are used exactly like the lua object returned by io.open
io.unlink("path"): Similar to os.remove. First return value is 0 in case
of success. In case of failure, the 2nd return parameter is an error
code to be compared against vlc.errno values.
unfortunately, even if I can locate the files, I cannot copy.
I have to use a os.execute with cmd (but if you know another way ?)

roland1
Blank Cone
Blank Cone
Posts: 44
Joined: 01 May 2014 16:49

Re: cannot copy file with special char in windows

Postby roland1 » 11 Jul 2018 20:15

but there is no io.copy.
true.
Untested:

Code: Select all

copy = function(from, to) local io = vlc.io or io local ff, err = io.open(from, "rb") if not ff then return nil, err end local ft, err = io.open(to, "wb") if not ft then return ft, err end local sz = 2^16 repeat local s = ff:read(sz) until not (s and ft:write(s)) ff:close() ft:close() return true end
unfortunately, even if I can locate the files, I cannot copy.
I have to use a os.execute with cmd (but if you know another way ?)
To help further I need code.


Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 10 guests