Avatar

Level 4

Thanks Craig and Abdul for your answers,

What i just read from your answers is so helpful but isn't my case here.

After a normal export all the files go to an export folder by default, then we have a workflow with a DOS Batch script that get executed every 20 minutes, and take all the files from the export folder and analyse them, after that, put each file in the user folder, here is the code that we use :

@echo off

SETLOCAL enableextensions enabledelayedexpansion

echo execute Export Script

set directory=G:\nac00\bin\Neolane\AdobeCampaignv6\var\nac_Homolog\export

set target_directory=!directory!\completed_files

set sql_file=!directory!\sql

set files_logs=!directory!\logs

if EXIST !directory! ( echo el directorio !directory! existe ) ELSE ( echo el directorio  !directory!  no existe )

if EXIST !target_directory! ( echo el directorio !target_directory! existe ) ELSE ( echo el directorio  !target_directory!  no existe )

if EXIST !sql_file! ( echo el directorio !sql_file! existe ) ELSE ( echo el directorio  !sql_file!  no existe )

if EXIST !files_logs! ( echo el directorio !files_logs! existe ) ELSE ( echo el directorio  !files_logs!  no existe )

set FECHA_COMPLETA=%date:~0,2%_%date:~3,2%_%date:~6,4% %time:~0,2%:%time:~3,2%:%time:~6,2%

set libelle_zip=%date:~0,2%%date:~3,2%%date:~6,4%%time:~0,2%%time:~3,2%%time:~6,2%

if EXIST !directory! ( echo el directorio !directory! existe ) ELSE ( echo el directorio  !directory!  no existe )

if EXIST !target_directory! ( echo el directorio !target_directory! existe ) ELSE ( echo el directorio  !target_directory!  no existe )

if EXIST !sql_file! ( echo el directorio !sql_file! existe ) ELSE ( echo el directorio  !sql_file!  no existe )

if EXIST !files_logs! ( echo el directorio !files_logs! existe ) ELSE ( echo el directorio  !files_logs!  no existe )

set FECHA_COMPLETA=%date:~0,2%_%date:~3,2%_%date:~6,4% %time:~0,2%:%time:~3,2%:%time:~6,2%

set libelle_zip=%date:~0,2%%date:~3,2%%date:~6,4%%time:~0,2%%time:~3,2%%time:~6,2%

echo ( generating files to export... please wait... )

IF NOT EXIST !directory!\ mkdir !directory!\

IF NOT EXIST !target_directory!\ mkdir !target_directory!\

IF NOT EXIST !files_logs!\ mkdir !files_logs!\

echo checking directory...

if EXIST !directory!\\*.* (

for %%x in (!directory!) do set /a count+=1

echo  total fichero: !count!

for %%a in (!directory!\*.*) do (

set fichero=%%~nxa

echo Fichero a revisar !fichero!

REM for /F "delims=" %%a in (!directory!\*.*) do (

REM InterfaceMDM

set interface=!fichero:~0,11!

IF NOT !interface! == "InterfaceMDM" (

set /A xresult=0

FOR /F "usebackq delims=!" %%s IN (` sqlplus -S NAC00/iheP8231@beox1d1v/DAC00_PRO @!sql_file!\export.sql !fichero! `) DO set /A xresult=%%s

echo estado Workflow !xresult!

if [!xresult!]==[5] (

set filialfolder=""

FOR /F "usebackq delims=!" %%m IN (` sqlplus -s NAC00/iheP8231@beox1d1v/DAC00_PRO @!sql_file!\folder_file.sql !fichero! `) DO set filialfolder=%%m

echo detectado Filial !filialfolder!

if not exist !target_directory!\!filialfolder! mkdir !target_directory!\!filialfolder!

if exist "!directory!\!fichero!" copy "!directory!\!fichero!" "!target_directory!\!filialfolder!\!fichero!"

echo !directory!\!fichero!

echo copy to 

echo !directory!\!fichero! !target_directory!\!filialfolder!\!fichero!

del "!directory!\!fichero!"

) ELSE (

echo Fichero no encontrado movido a !target_directory!\!fichero!.

copy "!directory!\!fichero!" "!target_directory!\!fichero!"

del "!directory!\!fichero!"

)

if exist !directory!\files_!libelle_zip!.txt copy !directory!\files_!libelle_zip!.txt !target_directory!\files_!libelle_zip!.txt

) ELSE (

echo fichero ignorado !interface!

)

)

) ELSE (

echo Fichero no encontrado e ignorado

)

This code stopped working (still not understanding the reason why), i tried to read it and figure it out but my knowledge with DOS Batch is very limited.

so if any one here can explain a little this code to me and what can be wrong with it, or a new way to do the same, to know the user who did the exported file and move the file to his folder.

Thanks,

Badr.