Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: shntools and cyrillic letters? (Read 2534 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

shntools and cyrillic letters?

Hi.
I'm running a batch script on a Windows 10 machine, using shntools to split album files into separate tracks.
Everything is working ok except for one thing. If the path of the output directory uses non western letters, e.g. cyrillic letters, shntools gives me a "can't find folder" and a path containing a lot of question marks "?" instead of the proper folder names.
Using chcp 866 works for the rest of the batch script but it doesn't help the shntools problem.
Is there a way to get shntools to work with folder names that include cyrillic letters?

Workaround:
If anyone has a way to extract the current folder name (not the entire path) from a .cue file I could use that to get around the whole issue.
Using a FOR /R loop forces me to use the whole path to create a new folder automatically in a different location and it's pretty ugly. Using a FOR /D loop won't let me execute the split in the initial folder that I drop on the batch script, it'll work fine on the subfolders though. Also a poor solution since I need to have the commands run in both the initial folder and the subfolders.
Using FINDSTR I can extract the line containing the .flac or .ape filename but I don't know how to extract the file name between the double quotations ("filename.ext") since " as delimiter seems to screw everything up? Grep doesn't work in windows, maybe there is a way to get around that?
I'm seriously considering switching to Linux since it seems to have much better command line tools.

Re: shntools and cyrillic letters?

Reply #1
1. Can you paste here your script/batch file?
2. What is your system locale? (Control Panel - Language - Change date, time, or number formats - Administrative - Language for non-Unicode programs).
3. Consider using PowerShell for scripting on Windows - full .NET stack is available for you.

Re: shntools and cyrillic letters?

Reply #2
I'm not at home at the moment but I'll paste the code when I get home.
I'll look into PowerShell as well.
Don't know the answer atm for the language settings, I'll have to look that up. I assume it's standard settings for English language?

Re: shntools and cyrillic letters?

Reply #3
I assume it's standard settings for English language?
In that case non-unicode programs will display '?' for unknown characters. Try to change this setting to "Russian" or other cyrillic language. It will not affect system UI language.

 

Re: shntools and cyrillic letters?

Reply #4
Huh, I never realized that might be the way to do it. I'll be sure to look into that.
I did come up with a workaround yesterday. Well, not to the cyrillic issue but the string parse one. However, life is filled with cruel little jokes like that one. I solved my issue with extracting the folder name but once I had it running I realized it was a Pyrrhic victory and that I'd painted myself into a corner, the computer will only do what I tell it to and it has no way of knowing the file structure unless I give it strict instructions about it.
I will look into the PowerShell as well, but now that I'm getting warmed up, I'm not sure it's needed?
Since the issues has sort of worked themselves out there isn't really any real reason for posting the code but I'll do it all the same just for completeness. Who knows, maybe it'll help someone else?
Code: [Select]
@echo off
SETLOCAL enabledelayedexpansion
FOR /R "%~1" %%I IN (*.cue) DO (
SET str=%%~dpI
for %%a in ("!str:~0,-1!") do (SET p=D:\Converted\%%~na\)
MKDIR "!p!"
pushd "!p!"
IF EXIST "%%~dpnI.ape" (shntool split -f "%%I" "%%~dpnI.ape" -m :-/-*x?! -t "%%n. %%t" -o flac)
IF EXIST "%%~dpnI.flac" (shntool split -f "%%I" "%%~dpnI.flac" -m :-/-*x?! -t "%%n. %%t" -o flac)
IF EXIST "%%~dpI*.jpg" (convert "%%~dpI*.jpg" -resize "400>" "!p!image-%%d.jpg")
IF EXIST "%%~dpI*.png" (convert "%%~dpI*.png" -resize "400>" "!p!image-%%d.jpg")
)

Needless to say, I miss the use of logic functions... It's a work in progress. :)