Welcome Guest ( Log In | Register )

FLAC support unicode?
post Sep 9 2006, 10:31
Post #1

Group: Members
Posts: 10
Joined: 15-August 06
Member No.: 34062

I am a newer for FLAC. I am using FLAC to convert wave files into flac. But if the filename or directory contians Chinese, the tools told me "Error: can not open input file F:\audio\---------------".

FLAC does not support UNICODE? I need to re-complile the FLAC project?

Go to the top of the page
+Quote Post
Start new topic
post Mar 18 2012, 22:37
Post #2

Group: Members
Posts: 1
Joined: 17-March 12
Member No.: 97870

To MiSP, whitejason and everybody who is having similar problem )

I could to offer my own version of a workaround to solve the problem with file names in Unicode on Windows. This is exactly as requested in the messages above -- slightly improved recursive script from the MiSP's post combined with the script by Egor. In my edition of the script the basic settings are in a separate section at the beginning (Adjustable parameters). There should be specified the actual path to the flac executable. Moreover, there are settings for the extensions of the source and destination files and a set of options for the encoder. In addition, during the process script prints the current working directory and names of the files which are being encoded at the moment. In my opinion, it's better than seeing only the progress for the current file, which displays flac, not knowing which particular file is re-encoded now.

Now a few words about the behavior of the script. The script traverses the subtree rooted at the current directory. In each directory of the subtree, the script enumerates all files with the extension "%srcext%" and passes them through a pipe to the encoder. The result flac writes to a temporary file with a name consisting of the name of the script and the current timestamp. If the processing was successful and the temporary file has been created, it is moved to a file with the same name as the original and the extension "%dstext%". If extensions of the input and the output files are the same, then the original file will be replaced by the newly created. To change this behavior is enough to specify an output file extension different from the original, such as "reenc.flac" or something along the same lines.

Below is the current version of the script (reflac.cmd), which has all the functionality described above and requires no additional tools to work:

:: This script is a wrapper for the flac command-line tool
:: to ensure proper handling of file names in unicode when transcoding
:: ---------------------------------------------------------------------
:: The script transcodes all the files with the given extension
:: in the current directory and all subdirectories. If the specified
:: extensions of source and destination files are the same
:: the original files will be replaced by the resulting.
:: Before use, you should specify the correct path to the flac
:: executable (in adjustable parameters section). In that section
:: can also be specified the extensions for the input and output
:: files, as well as set of options for the encoder.
:: ---------------------------------------------------------------------
:: reflac (mar 2012 by jar)

@echo off

setlocal enabledelayedexpansion

:: Adjustable parameters
:: ---------------------------------------------------------------------

set "encoder=с:\program files\flac\flac.exe"
set "options= --best --verify"

set "srcext=flac"
set "dstext=flac"

:: Print the header and create a line for underscore subheaders
:: ---------------------------------------------------------------------

echo %~n0: transcoding all the .%srcext% files in the current subtree

set "maxcol=79"

for /l %%i in (1, 1, %maxcol%) do (set "uline=!uline!-")

:: Traversing the directory subtree transcoding each target file
:: ---------------------------------------------------------------------

for /r %%d in (.) do (

set "dir=%%d"
set "dir=!dir:~0,-2!"

pushd "!dir!"

set "hasfiles="

for %%f in (*.%srcext%) do (
if not defined hasfiles (

echo %uline%
echo directory: !dir!
echo %uline%

set "hasfiles=true"

set "timestamp=!time:.=!"
set "timestamp=!timestamp::=!"
set "timestamp=!timestamp: =0!"

set "tempfile=%~n0-!timestamp!.tmp"

echo processing: %%f --^> *.%dstext%
echo %uline%

type "%%f" 2>nul | %encoder% %options% -o "!tempfile!" -

if exist "!tempfile!" (
move /y "!tempfile!" "%%~nf.%dstext%"



This post has been edited by jar: Mar 18 2012, 22:54

just jar
Go to the top of the page
+Quote Post

Posts in this topic

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 26th November 2015 - 10:46