Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageAppliance.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageAppliance.cpp	(revision 54978)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageAppliance.cpp	(revision 54979)
@@ -92,4 +92,6 @@
             else if (!RTStrNICmp(psz, "KeepNATMACs", len))
                 options->push_back(ImportOptions_KeepNATMACs);
+            else if (!RTStrNICmp(psz, "ImportToVDI", len))
+                options->push_back(ImportOptions_ImportToVDI);
             else
                 rc = VERR_PARSE_ERROR;
@@ -338,7 +340,7 @@
         if (retDisks.size() > 0)
         {
-            RTPrintf("Disks:");
+            RTPrintf("Disks:\n");
             for (unsigned i = 0; i < retDisks.size(); i++)
-                RTPrintf("  %ls", retDisks[i]);
+                RTPrintf("  %ls\n", retDisks[i]);
             RTPrintf("\n");
         }
@@ -634,21 +636,37 @@
                             {
                                 Utf8StrFmt strTypeArg("disk%u", a);
+                                RTCList<ImportOptions_T> optionsList = options.toList();
+
+                                bstrFinalValue = aVBoxValues[a];
+
                                 if (findArgValue(strOverride, pmapArgs, strTypeArg))
                                 {
-                                    RTUUID uuid;
-                                    /* Check if this is a uuid. If so, don't touch. */
-                                    int vrc = RTUuidFromStr(&uuid, strOverride.c_str());
-                                    if (vrc != VINF_SUCCESS)
+                                    if(!optionsList.contains(ImportOptions_ImportToVDI))
                                     {
-                                        /* Make the path absolute. */
-                                        if (!RTPathStartsWithRoot(strOverride.c_str()))
+                                        RTUUID uuid;
+                                        /* Check if this is a uuid. If so, don't touch. */
+                                        int vrc = RTUuidFromStr(&uuid, strOverride.c_str());
+                                        if (vrc != VINF_SUCCESS)
                                         {
-                                            char pszPwd[RTPATH_MAX];
-                                            vrc = RTPathGetCurrent(pszPwd, RTPATH_MAX);
-                                            if (RT_SUCCESS(vrc))
-                                                strOverride = Utf8Str(pszPwd).append(RTPATH_SLASH).append(strOverride);
+                                            /* Make the path absolute. */
+                                            if (!RTPathStartsWithRoot(strOverride.c_str()))
+                                            {
+                                                char pszPwd[RTPATH_MAX];
+                                                vrc = RTPathGetCurrent(pszPwd, RTPATH_MAX);
+                                                if (RT_SUCCESS(vrc))
+                                                    strOverride = Utf8Str(pszPwd).append(RTPATH_SLASH).append(strOverride);
+                                            }
                                         }
+                                        bstrFinalValue = strOverride;
                                     }
-                                    bstrFinalValue = strOverride;
+                                    else
+                                    {
+                                        //print some error about incompatible command-line arguments
+                                        return errorSyntax(USAGE_IMPORTAPPLIANCE,
+                                                           "Option --ImportToVDI shall not be used together with "
+                                                           "manually set target path.");
+
+                                    }
+
                                     RTPrintf("%2u: Hard disk image: source image=%ls, target path=%ls, %ls\n",
                                             a,
@@ -677,4 +695,81 @@
 #endif
                                 else
+                                {
+                                    strOverride = aVBoxValues[a];
+
+                                    /*
+                                     * Current solution isn't optimal. 
+                                     * Better way is to provide API call for function
+                                     * Appliance::i_findMediumFormatFromDiskImage()
+                                     * and creating one new function which returns
+                                     * struct ovf::DiskImage for currently processed disk.
+                                    */
+
+                                    /*
+                                     * if user wants to convert all imported disks to VDI format
+                                     * we need to replace files extensions to "vdi"
+                                     * except CD/DVD disks
+                                     */
+                                    if(optionsList.contains(ImportOptions_ImportToVDI))
+                                    {
+                                        ComPtr<IVirtualBox> pVirtualBox = arg->virtualBox;
+                                        ComPtr<ISystemProperties> systemProperties;
+                                        com::SafeIfaceArray<IMediumFormat> mediumFormats;
+                                        Bstr bstrFormatName;
+
+                                        CHECK_ERROR(pVirtualBox,
+                                                     COMGETTER(SystemProperties)(systemProperties.asOutParam()));
+
+                                        CHECK_ERROR(systemProperties,
+                                             COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats)));
+
+                                        /* go through all supported media formats and store files extensions only for RAW */
+                                        com::SafeArray<BSTR> extensions;
+
+                                        for (unsigned i = 0; i < mediumFormats.size(); ++i)
+                                        {
+                                            com::SafeArray<DeviceType_T> deviceType;
+                                            ComPtr<IMediumFormat> mediumFormat = mediumFormats[i];
+                                            CHECK_ERROR(mediumFormat, COMGETTER(Name)(bstrFormatName.asOutParam()));
+                                            Utf8Str strFormatName = Utf8Str(bstrFormatName);
+                                            
+                                            if (strFormatName.compare("RAW", Utf8Str::CaseInsensitive) == 0)
+                                            {
+                                                /* getting files extensions for "RAW" format */
+                                                CHECK_ERROR(mediumFormat,
+                                                            DescribeFileExtensions(ComSafeArrayAsOutParam(extensions),
+                                                                                   ComSafeArrayAsOutParam(deviceType)));
+                                                break;
+                                            }
+                                        }
+
+                                        /* go through files extensions for RAW format and compare them with
+                                         * extension of current file
+                                         */
+                                        bool b_replace = true;
+
+                                        const char *pszExtension = RTPathSuffix(strOverride.c_str());
+                                        if (pszExtension)
+                                            pszExtension++;
+
+                                        for (unsigned i = 0; i < extensions.size(); ++i)
+                                        {
+                                            Utf8Str strExtension(Bstr((extensions[i])));
+                                            if(strExtension.compare(pszExtension, Utf8Str::CaseInsensitive) == 0)
+                                            {
+                                                b_replace = false;
+                                                break;
+                                            }
+                                        }
+
+                                        if (b_replace==true)
+                                        {
+                                            strOverride = strOverride.stripSuffix();
+                                            strOverride = strOverride.append(".").append("vdi");
+                                        }
+                                    }
+
+                                    bstrFinalValue = strOverride;
+
                                     RTPrintf("%2u: Hard disk image: source image=%ls, target path=%ls, %ls"
                                             "\n    (change target path with \"--vsys %u --unit %u --disk path\";"
@@ -682,7 +777,8 @@
                                             a,
                                             aOvfValues[a],
-                                            aVBoxValues[a],
+                                            bstrFinalValue.raw(),
                                             aExtraConfigValues[a],
                                             i, a, i, a);
+                                }
                             }
                         break;
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 54978)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 54979)
@@ -409,5 +409,5 @@
                            "%s import %s          <ovfname/ovaname>\n"
                      "                            [--dry-run|-n]\n"
-                     "                            [--options keepallmacs|keepnatmacs]\n"
+                     "                            [--options keepallmacs|keepnatmacs|importtovdi]\n"
                      "                            [more options]\n"
                      "                            (run with -n to have options displayed\n"
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 54978)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 54979)
@@ -2941,4 +2941,8 @@
     </const>
 
+    <const name="ImportToVDI"       value="3">
+      <desc>Import all disks to VDI format</desc>
+    </const>
+
   </enum>
 
Index: /trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/ApplianceImpl.cpp	(revision 54978)
+++ /trunk/src/VBox/Main/src-server/ApplianceImpl.cpp	(revision 54979)
@@ -742,11 +742,35 @@
     if (strSrcFormat.isEmpty())
     {
+        strSrcFormat = di.strHref;
+
+        /* check either file gzipped or not
+         * if "yes" then remove last extension,
+         * i.e. "image.vmdk.gz"->"image.vmdk"
+         */
+        if (di.strCompression == "gzip")
+        {
+            if (RTPathHasSuffix(strSrcFormat.c_str()))
+            {
+                strSrcFormat.stripSuffix();
+            }
+            else
+            {
+                mf.setNull();
+                rc = setError(E_FAIL,
+                              tr("Internal inconsistency looking up medium format for the disk image '%s'"),
+                              di.strHref.c_str());
+                return rc;
+            }
+        }
         /* Figure out from extension which format the image of disk has. */
+        if (RTPathHasSuffix(strSrcFormat.c_str()))
         {
-            char *pszExt = RTPathSuffix(di.strHref.c_str());
+            const char *pszExt = RTPathSuffix(strSrcFormat.c_str());
             if (pszExt)
                 pszExt++;
             mf = pSysProps->i_mediumFormatFromExtension(pszExt);
         }
+        else
+            mf.setNull();
     }
     else
Index: /trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp	(revision 54978)
+++ /trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp	(revision 54979)
@@ -649,4 +649,12 @@
                         Utf8Str strTargetPath = Utf8Str(strMachineFolder);
                         strTargetPath.append(RTPATH_DELIMITER).append(di.strHref);
+                        /*
+                         * Remove last extension from the file name if the file is compressed
+                        */
+                        if(di.strCompression.compare("gzip", Utf8Str::CaseInsensitive)==0)
+                        {
+                            strTargetPath.stripSuffix();
+                        }
+
                         i_searchUniqueDiskImageFilePath(strTargetPath);
 
@@ -682,4 +690,12 @@
                             .append(RTPATH_DELIMITER)
                             .append(di.strHref);
+                        /*
+                         * Remove last extension from the file name if the file is compressed
+                        */
+                        if(di.strCompression.compare("gzip", Utf8Str::CaseInsensitive)==0)
+                        {
+                            strTargetPath.stripSuffix();
+                        }
+
                         i_searchUniqueDiskImageFilePath(strTargetPath);
 
@@ -2381,9 +2397,9 @@
                 /* Decompress the GZIP file and save a new file in the target path */
                 strTargetDir = strTargetDir.stripFilename();
-                strTargetDir.append("/temp_");
-
-                Utf8Str strTempTargetFilename(*strTargetPath);
+                strTargetDir.append(RTPATH_SLASH_STR);
+                strTargetDir.append("temp_");
+
+                Utf8Str strTempTargetFilename(strSrcFilePath);
                 strTempTargetFilename = strTempTargetFilename.stripPath();
-                strTempTargetFilename = strTempTargetFilename.stripSuffix();
 
                 strTargetDir.append(strTempTargetFilename);
@@ -2412,8 +2428,4 @@
                 /* Correct the source and the target with the actual values */
                 strSrcFilePath = strTargetDir;
-                strTargetDir = strTargetDir.stripFilename();
-                strTargetDir.append(RTPATH_SLASH_STR);
-                strTargetDir.append(strTempTargetFilename.c_str());
-                *strTargetPath = strTargetDir.c_str();
 
                 pRealUsedStorage = &finalStorage;
@@ -2421,15 +2433,52 @@
 
             Utf8Str strTrgFormat = "VMDK";
+            ComObjPtr<MediumFormat> trgFormat;
+            Bstr bstrFormatName;
             ULONG lCabs = 0;
 
-            if (RTPathHasSuffix(strTargetPath->c_str()))
-            {
-                const char *pszSuff = RTPathSuffix(strTargetPath->c_str());
-                /* Figure out which format the user like to have. Default is VMDK. */
-                ComObjPtr<MediumFormat> trgFormat = pSysProps->i_mediumFormatFromExtension(&pszSuff[1]);
+            //check existence of option "ImportToVDI", in this case all imported disks will be converted to VDI images
+            bool chExt = m->optListImport.contains(ImportOptions_ImportToVDI);
+
+            char *pszSuff = NULL;
+
+            if ((pszSuff = RTPathSuffix(strTargetPath->c_str()))!=NULL)
+            {
+                /* 
+                 * Figure out which format the user like to have. Default is VMDK
+                 * or it can be VDI if according command-line option is set
+                 */
+
+                /*
+                 * We need a proper target format
+                 * if target format has been changed by user via GUI import wizard
+                 * or via VBoxManage import command (option --importtovdi)
+                 * then we need properly process such format like ISO
+                 * Because there is no conversion ISO to VDI
+                 */
+
+                pszSuff++;
+                trgFormat = pSysProps->i_mediumFormatFromExtension(pszSuff);
                 if (trgFormat.isNull())
-                    throw setError(VBOX_E_NOT_SUPPORTED,
-                                   tr("Could not find a valid medium format for the target disk '%s'"),
-                                   strTargetPath->c_str());
+                {
+                    rc = setError(E_FAIL,
+                           tr("Internal inconsistency looking up medium format for the disk image '%s'"),
+                           di.strHref.c_str());
+                }
+
+                rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam());
+                if (FAILED(rc)) throw rc;
+
+                strTrgFormat = Utf8Str(bstrFormatName);
+
+                if(chExt && strTrgFormat.compare("RAW", Utf8Str::CaseInsensitive) != 0)
+                {
+                    /* change the target extension */
+                    strTrgFormat = "vdi";
+                    trgFormat = pSysProps->i_mediumFormatFromExtension(strTrgFormat);
+                    *strTargetPath = strTargetPath->stripSuffix();
+                    *strTargetPath = strTargetPath->append(".");
+                    *strTargetPath = strTargetPath->append(strTrgFormat.c_str());
+                }
+
                 /* Check the capabilities. We need create capabilities. */
                 lCabs = 0;
@@ -2450,8 +2499,4 @@
                                    tr("Could not find a valid medium format for the target disk '%s'"),
                                    strTargetPath->c_str());
-                Bstr bstrFormatName;
-                rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam());
-                if (FAILED(rc)) throw rc;
-                strTrgFormat = Utf8Str(bstrFormatName);
             }
             else
@@ -3808,4 +3853,5 @@
                 Utf8Str savedVBoxCurrent = vsdeTargetHD->strVBoxCurrent;
                 ComObjPtr<Medium> pTargetHD;
+
                 i_importOneDiskImage(diCurrent,
                                      &vsdeTargetHD->strVBoxCurrent,
