Setlocal
set PathDrive=%~d0
set PathInst=%~p0

set pathlog="%~d0%~p0\log\Preparar.log"
set datestamp=%date:~5%
set datestamp2=%datestamp:/=-%_%TIME::=-%

echo Iniciando preparación %datestamp2% >>%PathLog%


cls
c:
set bpath=c:\Servidor\Sistema\exportaciones\
set dpath=c:\Servidor\Sistema\Exportaciones_Preparado\
set xmask=*.xml
cd c:\Servidor\Sistema\Exportaciones_Preparado\
call :copyall %bpath% %dpath% %xmask% argentina
call :copyall %bpath% %dpath% %xmask% bolivia bo_
call :copyall %bpath% %dpath% %xmask% chile ch_
call :copyall %bpath% %dpath% %xmask% paraguay py_
call :copyall %bpath% %dpath% %xmask% uruguay ur_
call :copyall %bpath% %dpath% %xmask% usa us_
call :copyall2 %bpath% %dpath% %xmask% argentina\o-c OneClick


goto :eof

:copyall
c:
del "%2%4\*.*" /q
copy "%1%4\er\actual\%3" "%2%4"
copy "%1%4\oneclick\%3" "%2%4"
call :renfiles  %2%4 %5
goto :eof

:copyall2
c:
del "%2%5\*.*" /q
copy "%1%4\er\actual\%3" "%2%5"
copy "%1%4\oneclick\%3" "%2%5"
call :renfiles  %2%5 
goto :eof


:renfiles
cd %1
for %%j in (*.xml) do ren "%%j" "%2%%j"
ren "%2%2actual - cf - Cashfree.xml" "%2actual - cf - Cashfree.xml"
goto :eof

