Ms-Dos - Unir 2 códigos en un BAT

 
Vista:
sin imagen de perfil

Unir 2 códigos en un BAT

Publicado por Jose (1 intervención) el 14/04/2015 18:03:05
Hola, estoy trabajando con 2 ficheros BAT que por separado me funcionan perfectamente.

El tema es que estoy intentándo juntarlos para que funcionen con un solo ejecutable pero me da error.

Código 1: CONVIERTE EL ARCHIVO XLS EN TXT DELIMITADO POR COMAS

@echo off
set tmpVbs=nsbb.vbs
more +12 %0 >%tmpVbs%
for /f "tokens=*" %%a in (
'dir *.xls /a /b'
) do (
echo ???? %%a
wscript //Nologo "%tmpVbs%" "%%~dpnxa"
)
del "%tmpVbs%" /q 1>nul 2>nul
pause
Exit
Const xlCSV = 6
dim filepathname
Set objExcel = CreateObject("Excel.Application")
'Filename = objExcel.GetOpenFilename("Excel Files (*.xls), *.xls")
'objExcel.DisplayAlerts=FALSE
'If filename<>false Then
On Error Resume Next
Filename = WScript.Arguments.Unnamed.Item(0)
Set objWorkbook = objExcel.Workbooks.Open(Filename)
If Err.Number <> 0 Then
Err.Raise Err.Number
Return "-1"
End If
objWorkbook.SaveAs mid(Filename,1,len(Filename)-4) & ".txt",xlCSV
If Err.Number <> 0 Then
Err.Raise Err.Number
Return "-1"
End If
'MsgBox objWorkbook.path
filepathname = objWorkbook.path & "\\" & mid(Filename,1,len(Filename)-4) & ".txt"
objWorkbook.close false
'End If
objExcel.Quit
'MsgBox filepathname
'If filepathname>"" then
'Return filepathname
'end if

Código 2: SUSTITUYE LAS "," POR ";" EN EL ARCHIVO TXT CREADO

@echo off
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%x in ('type *.txt') do (
set linea=%%x
set linea=!linea:,=;!
call :show !linea!
)
goto:eof
:show
echo %* >> pedido.txt
goto:eof

A ver si alguien me puede echar una mano. Muchas gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder