Página 1 de 1
Descomponer Ruta ayuda
Publicado: 22 Jun 2017 21:36
por GEORGEFTR
Saludos me podrían ayudar a descomponer esta ruta con un botón D:\\DATOS GENERALES\\CARPETA 1\\ CARPETA 2\\archivo.txt
En un Label1 obtenga el datos de CARPETA 1, en un Label2 CARPETA2, Label3 archivo.
Saludos espero me puedan ayudar
Re: Descomponer Ruta ayuda
Publicado: 24 Jun 2017 03:33
por GEORGEFTR
Lo único que he podido es extraer el archivo con un ejemplo que entendí poco, no soy muy bueno.
a=string.match("D:\\SOLO PRUEBAS CARPETA 1\\SOLO PRUEBAS CARPETA 2\\ABRIR.EXE", "([^%\\]+)$");
Input.SetText("Input1", a)
Re: Descomponer Ruta ayuda
Publicado: 24 Jun 2017 23:12
por abood1987
Re: Descomponer Ruta ayuda
Publicado: 25 Jun 2017 02:12
por GEORGEFTR
path_parts = String.SplitPath("C:MyFolder 1 MyFolder 2 edit.exe");
drive =(path_parts.Drive.."");
folder =(path_parts.Folder.."");
ahora solo me quedan asi los folder \\folder 1\\folder 2\\
sigo buscando y solo me falta separar los folder cada uno en una input sin \\ he estado parte del dia y hasta ahi me quede
Re: Descomponer Ruta ayuda
Publicado: 27 Jun 2017 05:32
por GEORGEFTR
Re: Descomponer Ruta ayuda
Publicado: 05 Jul 2017 19:08
por Dow Sher
function Split_Path_Folder ( _Path )
local _Location, _nPath, _SplitPath_Folder
_SplitPath_Folder = {}
_Location = _Path:find('\\')
while _Location do
_nPath = _Path:sub ( 1, _Location-1 )
_Path = _Path:sub ( _Location+1, _Path:len() )
table.insert ( _SplitPath_Folder, (#_SplitPath_Folder)+1, _nPath )
_Location = _Path:find('\\')
end
return _SplitPath_Folder
end
function Split_Path ( _Path )
local _SplitPath, _nPath
_SplitPath = {}
if _Path:find("%w:\\?%w*.+") then
_nPath = String.SplitPath( _Path )
_SplitPath.Drive = _nPath.Drive
_SplitPath.FolderFull = _nPath.Folder
_SplitPath.Folders = Split_Path_Folder( _nPath.Folder:sub(2, _nPath.Folder:len()) )
if _nPath.Filename == "" then _SplitPath.Filename = "NO FILE" else _SplitPath.Filename = _nPath.Filename end
if _nPath.Extension == "" then _SplitPath.Extension = "NO FILE" else _SplitPath.Extension = _nPath.Extension end
else
_SplitPath["Error: El formato no es correcto"]
end
return _SplitPath
end
tblSplitPath = Split_Path ( Input.GetText("Input1") )
Debug.ShowWindow()
Debug.Print(tblSplitPath.Drive .. "\r\n")
Debug.Print(tblSplitPath.FolderFull .. "\r\n")
for _, _nElement in pairs ( tblSplitPath.Folders ) do
Debug.Print( _nElement .. "\r\n")
end
Debug.Print(tblSplitPath.Filename .. "\r\n")
Debug.Print(tblSplitPath.Extension .. "\r\n")
-- [[ === RUTAS VÁLIDAS Y NO VÁLIDAS === ]] --
"C:\USERS\DESKTOP\FILE.EXE" -- RUTA VÁLIDA
"C:\USER\DESKTOP\" -- RUTA VÁLIDA
"C:\USER\DESKTOP" -- RUTA NO VÁLIDA (EL ÚNICO ELEMENTO QUE NO DEBE TENER LA DIAGONAL AL FINAL ES EL ARCHIVO, SI A UNA CARPETA NO LE PONES LA DIAGONAL TE LO RECONOCERÁ COMO ARCHIVO)
Re: Descomponer Ruta ayuda
Publicado: 06 Jul 2017 02:32
por GEORGEFTR
Muchas gracias por sus respuestas esta ayuda si la veo muy compleja la voy a repasar, saludos y de nuevo gracias.