I'm working on moving the content of a website, which was provided to me in a RAR archive, to a new server.

I'm not exactly sure which flavor of Linux it is; uname -a tells me:

Linux bolt.sonic.net #1 SMP Mon Aug 17 10:15:36 PDT 2009 i686 unknown

and unrar --help tells me:

UNRAR 3.00 freeware      Copyright (c) 1993-2002 Eugene Roshal

I'm not a regular user of unrar, but in my limited prior experience, the simple command unrar x archive.rar has always done the right thing, as far as I can remember.

But when I try to unpack the current archive, the result is a flat-structured directory containing 4500-odd files and directories whose names have backslashes in them where directory-separators should be, e.g.:

drwxr-xr-x    2 yoyodyne user         4096 Jan 18 14:53 yoyodyne
drwxr-xr-x    2 yoyodyne user         4096 Jan 18 14:53 yoyodyne\application
drwxr-xr-x    2 yoyodyne user         4096 Jan 18 14:53 yoyodyne\application\config
-rw-r--r--    1 yoyodyne user         2765 Sep 15  2011 yoyodyne\application\config\database.php
-rw-r--r--    1 yoyodyne user         1152 Sep 15  2011 yoyodyne\application\config\doctypes.php
-rw-r--r--    1 yoyodyne user         1844 Sep 15  2011 yoyodyne\application\config\foreign_chars.php
-rw-r--r--    1 yoyodyne user          513 Sep 15  2011 yoyodyne\application\config\hooks.php
-rw-r--r--    1 yoyodyne user          123 Sep 15  2011 yoyodyne\application\config\index.html

I'm at a complete loss to understand what's causing this to happen, or how to get around it. I'm not seeing any obvious options on the unrar command that tell it, for instance, "Hey, I'm on a Linux system", or "Hey, ignore the fact that this archive was created on a Windows system."

(Actually, I don't know whether the archive was created on a Windows system or not. The developer who sent me the archive didn't say, and promptly went on vacation immediately afterwards -- meaning that my chances of getting an answer, or a replacement archive in a different format, are slim.)

For what it's worth, the unrar program seems to understand that the part of the name after the last backslash is the actual filename. The part of the output of unrar l archive.rar corresponding to the partial directory listing above is:

 Name             Size   Packed Ratio  Date   Time     Attr      CRC   Meth Ver
 database.php     2765     1071  38% 15-09-11 10:57   .....A   13CDB2C8 m3g 2.9
 doctypes.php     1152      381  33% 15-09-11 10:57   .....A   F25E706F m3g 2.9
 foreign_chars.php     1844      856  46% 15-09-11 10:57   .....A   12AF75FD m3g 2.9
 hooks.php         513      285  55% 15-09-11 10:57   .....A   4029E30E m3g 2.9
 index.html        123      107  86% 15-09-11 10:57   .....A   E8DFAEB4 m3g 2.9
 config              0        0   0% 18-01-13 14:53   .D....   00000000 m0  2.0
 application         0        0   0% 18-01-13 14:53   .D....   00000000 m0  2.0

So given this, and given that the unrar program is running on a Linux system, why is it creating these crazy filenames? And what can I do about it?

  • I think the bolt.sonic.net shell server runs Red Hat. Is there any way you can run a newer version of unRAR to see if it behaves the same way?
    – Karan
    Feb 1, 2013 at 0:55
  • Maybe, but probably not today. And almost certainly not on a sonic.net server (which means that when I do get a chance to run it, I'll be changing two variables). For the moment I'm trying to work around it by unarchiving on my Mac laptop (via Stuffit Expander) and then creating a tar archive to upload. Hopefully sonic.net can do the right thing with a tar archive. :-/ Thanks for the tip about them running Red Hat...
    – Hephaestus
    Feb 1, 2013 at 1:07
  • uname -a tell you which Linux (kernel) version it is. I assume you wanted to find out which distribution (e.g. CentOS, Debian, Ubuntu, ...) it is. As far as I know there is no command to discover that, though ls /etc might help. (e.g. if it has a file slackware-version then it is slackware). Are for rar, my rar claims UNRAR 4.20 freeware Copyright (c) 1993-2012 Alexander Roshal. Which means there is a newer version and you can test that (either on the destination, or try it first on your laptop to check if it works).
    – Hennes
    Feb 1, 2013 at 11:28
  • Actually, I ran uname -a mainly so that I could include the output in my OP, in case any part of what it said might be helpful in figuring out the problem. :-) As to running a newer version of unrar on the sonic.net server, I now see that my earlier remark ("almost certainly not on a sonic.net server") was a little premature, since I could upload an executable myself, assuming I can find or build an architecturally-compatible one. Or maybe I could even build from source on the sonic.net server, if they have the necessary build tools.
    – Hephaestus
    Feb 1, 2013 at 15:49
  • @Hennes You might be interested in this: cyberciti.biz/faq/find-linux-distribution-name-version-number . I tried the cat /etc/*-release suggestion on the Sonic.net shell server and got Red Hat Linux release 7.3 (Valhalla).
    – Hephaestus
    Feb 2, 2013 at 2:07

1 Answer 1


I don't know the solution for unrar itself, but if you can run vidir and if you manage to unpack the archive content as a flat-structured directory, then this is what you may try to convert it to a directory tree:

# cd to the directory
find . | sort | vidir -

This will open your text editor. Use its features to replace every \ with / and save the file without changing its path (it's a temporary file). vidir will move files and directories to their new paths, creating the desired directory tree.


  • Fancy characters in filenames are not supported, vidir expects textual input with standard newlines as entry separators (it won't work with find . -print0 or sort -z).
  • I used sort to ensure every line representing a directory precedes its content-to-be. It's important because vidir will create missing directories while moving an object to its new path. Moving the original directory later would generate a name conflict resolvable with ~ suffix, you don't want this. You want to move the directory before its content, hence sort.
  • Set $EDITOR to make vidir use text editor of your choice (e.g. EDITOR=vi vidir).
  • You can try the experimental approach from my other answer to replace characters automatically, without playing in text editor by hand. In your case the command will be:

    find . | sort | EDITOR='sed -i s|\\|/|g' vidir -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.