Página 1 de 1

[Funcion] Folder.Move

Publicado: 13 Mar 2011 10:41
por Ceone
Buenas amigos de amsspecialist.info, hoy mirando en el foro de ru-board he visto un script que me a parecido interesante la verdad es que no lo he probado pero a simple vista parece qye funciona correctamente espero que os guste y os sea de gran utilidad.
function Folder.Move(sInFolderPath, sDestFolderPath)
    sInFolderPath = String.TrimRight(sInFolderPath, "\\");
    sDestFolderPath = String.TrimRight(sDestFolderPath, "\\").."\\"..String.Mid(sInFolderPath, String.ReverseFind(sInFolderPath, "\\", false) + 1, -1);
    if not Folder.DoesExist(sDestFolderPath) then
        Folder.Create(sDestFolderPath);
    end
    File.Move(sInFolderPath.."\\*.*", sDestFolderPath, true, true, false, true, nil);
    -- Test for error
    error = Application.GetLastError();
    if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    else
        Folder.Delete(sInFolderPath);
    end
end
--************************
local sDir = Dialog.FolderBrowse("Please select a folder:", "AutoPlay\\Docs");
if sDir ~= "CANCEL" then
    Folder.Move('C:\\Downloads', sDir);
end

Re: [Funcion] Folder.Move

Publicado: 05 Abr 2011 12:57
por carsonzillo
Hola Ceone XD

Te he perfeccionado un poquito el script ya que le farta el progress:

function Folder.Move(sInFolderPath, sDestFolderPath)

	
    
    StatusDlg.Show();
	StatusDlg.ShowCancelButton(true, "Cancelar el movimiento");
	StatusDlg.SetMeterRange(0, "100");-- finish limit at 100 %
	actual = StatusDlg.GetMeterPos();--detect current pos
	StatusDlg.SetMeterPos(actual);
	nPercentage = Math.Floor(actual / 100);
	StatusDlg.SetTitle("Moviendo al (" .. nPercentage .. "%)...");
	
	
    sInFolderPath = String.TrimRight(sInFolderPath, "\\");
    sDestFolderPath = String.TrimRight(sDestFolderPath, "\\").."\\"..String.Mid(sInFolderPath, String.ReverseFind(sInFolderPath, "\\", false) + 1, -1);
    if not Folder.DoesExist(sDestFolderPath) then
        Folder.Create(sDestFolderPath);
    end
    File.Move(sInFolderPath.."\\*.*", sDestFolderPath, true, true, false, true, nil);
    -- Test for error
    error = Application.GetLastError();
    if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    else
	    Folder.DeleteTree(sInFolderPath, nil);

    end
    
    
    if StatusDlg.IsCancelled() then-- si se cancela se corta la operacion
		StatusDlg.Hide();
		return false;
	else
		if nCopBytes == nTotBytes then
			StatusDlg.SetStatusText("Terminado!");
			Application.Sleep(1000);
			StatusDlg.Hide();
			return false;
		else
			return true;
		end
	end
end
--************************
local sDir = Dialog.FolderBrowse("Please select a folder:", "AutoPlay\\Docs");--ELIGE UNA RUTA
if sDir ~= "CANCEL" then
    Folder.Move('C:\\TUCARPETA', sDir);--CAMBIA TU CARPETA POR LA QUE QUIERAS MOVER
end





Re: [Funcion] Folder.Move

Publicado: 05 Abr 2011 17:23
por Ceone
esta bien pero abria sido mejor crear un callback que meter el status ay del palazo... :D pero bueno todo sea por mejorar!

Re: [Funcion] Folder.Move

Publicado: 05 Abr 2011 18:07
por carsonzillo
tal vez podria haber creado una minifuncion para el status pero weno con esto funciona bien XD ademas quedaba feo sin saber si estaba moviendose o no asi que te lo he puesto XD como dice el lechu haciendo un poco el tocacoj XDDD

Re: [Funcion] Folder.Move

Publicado: 05 Abr 2011 18:12
por Ceone
bueno la cuestión es ir haciendo... y aprendiendo mientras vas haciendo...!!

Re: [Funcion] Folder.Move

Publicado: 18 Ago 2011 00:04
por abood1987
thanks

good

Re: [Funcion] Folder.Move

Publicado: 19 Ago 2011 00:23
por Thedary
No creo que fuera necesario el Progress, porque asi la funcion seria mas multiproposito.. Pero esta bueno tu código @</span>

Publicado: 23 Dic 2013 02:42
por ZyA
Buenisimo me funciono perfecto en mi proyecto gracias