[OT] Corrupted characters when piping DIR to file

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
StickyNomad
Power Member
Power Member
Posts: 1933
Joined: 2004-01-10, 00:15 UTC
Location: Germany

[OT] Corrupted characters when piping DIR to file

Post by *StickyNomad »

I'd like to create .m3u playlists using the tiny ol' DOS Dir command:

Code: Select all

%comspec% /c "dir /b /ogn *.mp3 >Playlist.m3u"
and this works quite well, but special characters are a real hassle. If the filenames contain german umlauts or abostrophes etc., these are converted and so the according playlist entry gets corrupted. I assume DIR creates ASCII output and it should be ANSI to work. On the dos-console, the output of the above command is shown correctly, this occurs only when piping to a file.

I tried out to set 'COUNTRY=...' in config.nt or to use CMDs /u and /a parameters and other tricks, but nothing worked and I could't find a concrete solution for this issue anywhere. Maybe someone can draw a quick solution or a tiny 3rd party-commandline-tool out of his pocket?

I also tried the WDX Infopacker-plugin, but I've seen no option to set its output filename which I'd like to be always 'Playlist.m3u'. AFAIK only the extension can be specified in this tool.
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Change the codepage first:

Code: Select all

Command: %comspec% /c
Parameter: CHCP 1252&dir /b /ogn *.mp3 >Playlist.m3u
Edit: This doesn't work although it should.

You have to create a batch instead, put this in "playlist.bat":

Code: Select all

CHCP 1252
dir /b /ogn *.mp3 >Playlist.m3u
Then create a button:

Code: Select all

Command: %comspec% /c
Parameter: playlist.bat
Icfu
Last edited by icfu on 2006-01-16, 15:35 UTC, edited 1 time in total.
This account is for sale
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

Well, AutoHotkey is in my pocket:

Code: Select all

Loop %A_WorkingDir%\*.mp3
	FileAppend %A_LoopFileName%`n, Playlist.m3u
I switched to Linux, bye and thanks for all the fish!
User avatar
Sir_SiLvA
Power Member
Power Member
Posts: 3378
Joined: 2003-05-06, 11:46 UTC

Post by *Sir_SiLvA »

How about (i think posted somewhere here by ICFU)

Command: cmd.exe
Paramter: /C copy /y "%F" "%P\Playlist.m3u"
Hoecker sie sind raus!
User avatar
StickyNomad
Power Member
Power Member
Posts: 1933
Joined: 2004-01-10, 00:15 UTC
Location: Germany

Post by *StickyNomad »

Well, thank y'all for your comprehensive help! I tried around and think I'll stick with icfu's solution. The Autohotkey script needs quite a few seconds to execute and if a playlist already exists, the script appends the files to the actual content of the playlist. Sorry SanskritFritz & Sir_SiLvA, but many thanks though :D

I added a one-level backup function if 'Playlist.m3u' already exists and now the BAT fits perfect:

Code: Select all

CHCP 1252
IF EXIST Playlist.m3u ren Playlist.m3u Playlist_old.m3u
dir /b /ogn *.mp3 >Playlist.m3u

2SanskritFritz
Perhaps you should consider changing your nick to 'AutohotkeyFritz'? I don't know your Sanskrit skills, but with Autohotkey, you're definetely the man and your pocket o' scripts seems to be bottomless! :D
Post Reply