A relative of mine asked me to restore a couple of files from backup CDs created by the windows native backup utility.
It turned out more difficult than I initially expected.
First, unlike other tools, the windows backup utility zips the files using the backslash as a directory separator and none of the Linux decompression tools can handle that.
Second, the files were encoded with one of the Windows native encodings, and none of the Linux decompression tools handle that (apparently unzip on Ubuntu is patched to add support for filename encodings, but Debian, as usual, is lacking).
What a mess ...
1. unzip with bsdtar as unzip would scramble the non-ascii filenames
$ bsdtar xf ../Backup\ files\ 7.zip
2. convert filenames to utf-8
$ convmv -r -f cp852 -t utf-8 --notest .
3. recreate the directory structure
$ cat y.py
#! /usr/bin/env python
import os
import errno
# already created directories, walk works topdown, so a child dir
# never creates a directory if there is a parent dir with a file.
made_dirs = set()
for root, dir_names, file_names in os.walk('.'):
for file_name in file_names:
if '\\' not in file_name:
continue
alt_file_name = file_name.replace('\\', '/')
if alt_file_name.startswith('/'):
alt_file_name = alt_file_name[1:] # cut of starting dir separator
alt_dir_name, alt_base_name = alt_file_name.rsplit('/', 1)
print('alt_dir', alt_dir_name)
full_dir_name = os.path.join(root, alt_dir_name)
if full_dir_name not in made_dirs:
try:
os.makedirs(full_dir_name)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(full_dir_name):
# the pass already exists and is a folder, let's just ignore it
pass
else:
raise
made_dirs.add(full_dir_name)
os.rename(os.path.join(root, file_name),
os.path.join(root, alt_file_name))
$ python y.py
Wednesday, November 1, 2017
Friday, March 10, 2017
Turris becomes mine
Three years ago I was lent one of the test Turris routers, that later became Turris Omnia. As promised, I'm now able to buy the machine for a symbolic prize of 1 CZK (0.04 USD).
Thursday, January 26, 2017
Wednesday, January 11, 2017
[SOLVED] Microphone stops working when I plug in my headset
Recently I joined a phone meeting and only after a while I realized the other participants couldn't hear me.
Rather an embarrassing experience...
The laptop's built in microphone works fine, but as soon as I plug in my headset it's muted.
Apparently Windows, or the audio driver, think the device I plugged in has a microphone when it hasn't or vice versa.
The solution is to go to Control Panels, Realtek HD Audio Manager, in the top left corner click the Folder icon next to the analog hole image, and tick the 'Enable auto popup dialog' checkbox.
With this done, when one plugs a headset, windows will ask what type it is and act accordingly.
Yay!
Rather an embarrassing experience...
The laptop's built in microphone works fine, but as soon as I plug in my headset it's muted.
Apparently Windows, or the audio driver, think the device I plugged in has a microphone when it hasn't or vice versa.
The solution is to go to Control Panels, Realtek HD Audio Manager, in the top left corner click the Folder icon next to the analog hole image, and tick the 'Enable auto popup dialog' checkbox.
With this done, when one plugs a headset, windows will ask what type it is and act accordingly.
Yay!
Friday, September 30, 2016
Where to put update zips for CyanogenMod 13
On my nicki device, the cyanogenmod updater downloads the updates to /storage/emulated/0/cmupdater, so when it reboots to recovery, they aren't available.
They have to be moved to /data/media to be usable.
They have to be moved to /data/media to be usable.
Tuesday, September 13, 2016
Living without Google Play
Amid the news about Google Play turning on location tracking without consent, let me share how to avoid it.
Step one - install CyanogenMod on your phone.
Step two - do not install Google Play.
Now you have a clean foundation to build on, but how to install apps without Google Play? That's actually quite easy - most opensource apps can be had at the F-Droid store.
To install proprietary apps, I use Raccoon on my desktop to download the apk files from Google Play. Once I move them to the phone they can be installed by tapping on them in the file manager.
Step one - install CyanogenMod on your phone.
Step two - do not install Google Play.
Now you have a clean foundation to build on, but how to install apps without Google Play? That's actually quite easy - most opensource apps can be had at the F-Droid store.
To install proprietary apps, I use Raccoon on my desktop to download the apk files from Google Play. Once I move them to the phone they can be installed by tapping on them in the file manager.
Thursday, September 8, 2016
Sony headphones useful again
The headphones from my old Xperia Ray turned out to be incompatible with my new Xperia M. They are still fine, but I can't use them with the new phone.
Also they can't be used with a simple MP3 player as the TRRS jack passes the audio output through the microphone, so it's barely audible.
There's the 'press mute button' workaround, but it's quite user unfriendly to keep holding it while cycling...
So, to fix them permanently, I opened the microphone enclosure (a fingernail works well).
You'll notice the two wires marked G and R that connect the mute button.
When shorted, the effect is the same as if the mute button was pressed permanently. And that's what I've done.
A blip of the solder gun and the headphones can be used!
Also they can't be used with a simple MP3 player as the TRRS jack passes the audio output through the microphone, so it's barely audible.
There's the 'press mute button' workaround, but it's quite user unfriendly to keep holding it while cycling...
So, to fix them permanently, I opened the microphone enclosure (a fingernail works well).
You'll notice the two wires marked G and R that connect the mute button.
When shorted, the effect is the same as if the mute button was pressed permanently. And that's what I've done.
A blip of the solder gun and the headphones can be used!
Subscribe to:
Posts (Atom)


