Vai al contenuto

Cpy2Audtrl.cmd

Cpy2Audtrl.cmd

@echo off

:: cls sta per clear screen
cls

setlocal enabledelayedexpansion
:: dettaglio comandi setlocal 
:: sintassi
::		setlocal [enableextensions | disableextensions] [enabledelayedexpansion | disabledelayedexpansion]
::		ENABLEEXTENSIONS
::			Abilita le estensioni ai comandi fino a corrispondenti endlocal comando viene rilevato, indipendentemente dall'impostazione prima il setlocal comando è stato eseguito.
::		DISABLEEXTENSIONS
::			Disabilita le estensioni ai comandi fino a quando la corrispondenza endlocal comando viene rilevato, indipendentemente dall'impostazione prima di setlocal comando è stato eseguito.
::		ENABLEDELAYEDEXPANSION
::			Consente l'espansione della variabile di ambiente ritardata fino a quando la corrispondenza endlocal comando viene rilevato, indipendentemente dall'impostazione prima di setlocal comando è stato eseguito.
::		DISABLEDELAYEDEXPANSION
::			Disabilita l'espansione della variabile di ambiente ritardata fino a quando la corrispondenza endlocal comando viene rilevato, indipendentemente dall'impostazione prima di setlocal comando è stato eseguito.
::		/?
::			Visualizza la guida al prompt dei comandi.

:: richiama il file config.cmd (che contiene i dettagli di tutte le postazioni Analyst)
call config.cmd

:: setESC funzione per i colori del propt
:: https://www.codeproject.com/Questions/5250523/How-to-change-color-of-a-specific-line-in-batch-sc
:: https://stackoverflow.com/questions/2048509/how-to-echo-with-different-colors-in-the-windows-command-line
call :setESC

set destPath=T:\audtrl
set /a checkPrint=0
set len=0
set L=0
set LL=0
set /a check=0
:: -------------------------------------------------------------------------------------------------------------------
:CountMatrixElement
::		It will check if the element is defined or not
IF defined array[%len%].Name (
	set /a len+=1
	GOTO :CountMatrixElement 
)
:: echo The length of the array array is %len%
:: -------------------------------------------------------------------------------------------------------------------
:PrintInfo
IF defined array[%LL%].Name (
	IF "%checkPrint%"=="0" (
		goto :PrintHead	
	) ELSE IF "%checkPrint%"=="1" (
		goto :PrintBody
	) ELSE IF "%checkPrint%"=="2" (
		goto :PrintFoot
	)
)
goto :PrintFoot
:: -------------------------------------------------------------------------------------------------------------------
:findMachine
IF defined array[%L%].Name (
	IF "!array[%L%].Number!"=="%Machine%" (
		set ip=!array[%L%].Name!
		set fromPath=!array[%L%].Path!
		set /a check+=1
	) ELSE (
		set /a L+=1
		GOTO :findMachine
	)
)
IF "%check%"=="1" (
	call echo 	======================================================================================================
	call echo 	===========================%ESC%[92m* Il numero strumento inserito e' stato trovato *%ESC%[0m==========================
	call echo 	======================================================================================================
	GOTO :Continue
	) ELSE IF "%check%"=="0" (
	call echo 	======================================================================================================
	call echo 	=========================%ESC%[91m* Il numero strumento inserito NON e' stato trovato *%ESC%[0m========================
	call echo 	======================================================================================================
	pause
	GOTO :eof
)
:: -------------------------------------------------------------------------------------------------------------------
:PrintHead
echo 	%ESC%[34;4m                                                                                                      %ESC%[0m
echo 	%ESC%[34;7;46m                                       ERBC-GROUP  Copy2audtrl                                        %ESC%[0m
::echo	%ESC%[34m                                                                                                      %ESC%[0m

echo 	%ESC%[4;30;47m                                           Elenco Strumenti                                           %ESC%[0m
echo 	%ESC%[36mNumero Strumento	-	Nome Macchina	-	Strumento	-	Workstation Name%ESC%[0m
echo. 
set /a checkPrint+=1
GOTO :PrintBody
:: -------------------------------------------------------------------------------------------------------------------
:PrintBody
echo 		!array[%LL%].Number!		%ESC%[91m-%ESC%[0m	!array[%LL%].Name2!	%ESC%[91m-%ESC%[0m	!array[%LL%].Strumento!	%ESC%[91m-%ESC%[0m	!array[%LL%].WorkstationName!
echo.
set /a LL+=1
GOTO :PrintInfo
:: -------------------------------------------------------------------------------------------------------------------
:PrintFoot
echo 	%ESC%[4;34m                                                                                                      %ESC%[0m
echo 	%ESC%[100m(esempio, inserisci AMC433 per indicare la macchina chiamata ULTIMO)%ESC%[0m
echo.
set Machine=
SET/P Machine=%ESC%[1mNumero Strumento :%ESC%[0m
echo.
GOTO :findMachine
:: -------------------------------------------------------------------------------------------------------------------
:Continue
set from=\\%ip%\%fromPath%
setlocal enabledelayedexpansion
echo 	%ESC%[4m                                                                                                      %ESC%[0m
echo 	%ESC%[4;30;47m                                   Elenco cartelle trovate in %Machine%                                  %ESC%[0m
echo.
for /d %%x in ("%from%"\*) do (
    set line=%%~nx
    echo 	%ESC%[1m!line!%ESC%[0m
)
echo 	%ESC%[4;34m                                                                                                      %ESC%[0m
echo.
set Studio=
set /P Studio=%ESC%[1mCartella da spedire :%ESC%[0m
::echo.
IF exist "\\%ip%\%fromPath%\%Studio%" (
	echo. 
) ELSE (
    echo 	%ESC%[101m                                                                                                      %ESC%[0m
	echo 	%ESC%[91m                                  IL NOME CARTELLA INSERITO NON ESISTE                                %ESC%[0m
	echo 	%ESC%[101m                                                                                                      %ESC%[0m
	echo.
	pause
	GOTO :eof
)

set StudyFolder=
set /P StudyFolder=%ESC%[1mSpecificare la cartella Studio da creare nella destinazione :%ESC%[0m
echo.

set SF=
set /P SF=Digita (%ESC%[92m1%ESC%[0m) per creare la cartella "%ESC%[91mBIO%ESC%[0m" oppure digita (%ESC%[92m2%ESC%[0m) per creare la cartella "%ESC%[91mForm%ESC%[0m" :

echo.

IF "%SF%" == "1" (
    set subFolder=BIO
) ELSE IF "%SF%" == "2" (
    set subFolder=Form
) ELSE (
    echo 	%ESC%[101m                                                                                                      %ESC%[0m
	echo    %ESC%[91m                                        IL VALORE INSERITO NON E' CORRETTO                                %ESC%[0m
	echo    %ESC%[91m                                       IL PROCESSO DI COPIA SARA' ANNULLATO                               %ESC%[0m
	echo 	%ESC%[101m                                                                                                      %ESC%[0m
	echo.
	pause
	GOTO :eof
)
set fromDir=\\%ip%\%fromPath%\%Studio%
set archDir=%destPath%\%StudyFolder%\%subFolder%\%Machine%

IF exist %archDir% ( 
	echo 	%ESC%[91m______________________________________________________________________________________________________%ESC%[0m
	echo 	%ESC%[91m======================================================================================================%ESC%[0m
	echo					LA CARTELLA %archDir% ESISTE GIA'
	echo					I FILE GIA' PRESENTI NELLA CARTELLA %subFolder%
	echo					QUAL'ORA AVESSERO LO STESSO NOME I FILE NON VERRANNO COPIATI
	echo 	%ESC%[91m______________________________________________________________________________________________________%ESC%[0m
	echo 	%ESC%[91m======================================================================================================%ESC%[0m
	echo.
)
echo 	%ESC%[34;4m                                                                                                      %ESC%[0m
echo.
echo		Il contenuto dello studio               %ESC%[92m%Studio%%ESC%[0m
echo		situato sul numero strumento            %ESC%[92m%Machine%%ESC%[0m
echo		verra' copiato nel seguente percorso:   %ESC%[92m%archDir%%ESC%[0m
echo 	%ESC%[34;4m                                                                                                      %ESC%[0m
echo.
set response=
set /P response=Confermi l'operazione di copia? (%ESC%[92ms%ESC%[0m/%ESC%[92mn%ESC%[0m) :
IF "%response%" == "n" (
	echo.
	echo 	%ESC%[101m                                                                                                      %ESC%[0m
	echo 	%ESC%[91m                               NESSUNA OPERAZIONE DI COPIA E' STATA ESEGUITA%ESC%[0m
	echo 	%ESC%[101m                                                                                                      %ESC%[0m
	echo.
	pause
    GOTO :eof
) ELSE IF "%response%" == "s" (
	GOTO :Copy  
) ELSE (
	echo 	%ESC%[101m                                                                                                      %ESC%[0m
	echo 	%ESC%[101m %ESC%[0m                                      %ESC%[91mVALORE INSERITO NON VALIDO%ESC%[0m                                    %ESC%[101m %ESC%[0m
	echo 	%ESC%[101m                                                                                                      %ESC%[0m
	pause
    GOTO :eof
)
:: -------------------------------------------------------------------------------------------------------------------
:Copy
robocopy "%fromDir%" "%archDir%" /E /LOG:LogInvio.txt /TS /NC /FP /NP /ETA /NJH /TEE

:: dettaglio comandi ROBOCOPY
:: /E Copia le sottodirectory. Questa opzione include automaticamente directory vuote.
:: /LOG:<logfile>	Scrive l'output di stato nel file di log sovrascrivendo il file di log esistente.
:: /TS Include i timestamp del file di origine nell'output.
:: /NC Specifica che le classi di file non devono essere registrate.
:: /FP Include i nomi di percorso completi dei file nell'output.
:: /NP Specifica che lo stato dell'operazione di copia (il numero di file o directory copiati finora) non deve essere visualizzato.
:: /ETA Mostra il tempo stimato di arrivo (ETA) dei file copiati.
:: /NJH Specifica che non è presente alcuna intestazione del processo.
:: /TEE Scrive l'output dello stato nella finestra della console, nonché nel file di log.

REM robocopy "%fromDir%" "%archDir%" /E /A+:RA /LOG:LogInvio.txt /TS /NC /FP /NP /ETA /NJH /TEE
REM robocopy "%fromDir%" "%archDir%" /E /MOVE /A+:RA /LOG:LogInvio.txt /TS /NC /FP /NP /ETA /NJH /TEE

IF %time:~0,2% leq 9 (
	set orainvio=%date:~6,4%%date:~3,2%%date:~0,2%_0%time:~1,1%%time:~3,2%%time:~6,2%
) ELSE (
	set orainvio=%date:~6,4%%date:~3,2%%date:~0,2%_%time:~0,2%%time:~3,2%%time:~6,2%
)
ren LogInvio.txt LogInvio_%orainvio%.txt
attrib +r +a LogInvio_%orainvio%.txt
move LogInvio_%orainvio%.txt "%archDir%\LogInvio_%orainvio%.txt"

REM mettere REM alla riga successiva per togliere autoprint
notepad.exe /p "%archDir%\LogInvio_%orainvio%.txt"
notepad.exe "%archDir%\LogInvio_%orainvio%.txt"
del Chem2Arc.cmd
GOTO :eof
endlocal

:setESC
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
  set ESC=%%b
  exit /B 0
)

config.cmd

@echo off

:: Macchine in dismissione
set array[0].Number=AMC235
set array[0].Name=NB-34PTC63
set array[0].Name2=PENELOPE
set array[0].Strumento=API 2000
set array[0].WorkstationName=RT4202ANALYST ... in dismiss
set array[0].Path=c$\SCIEX OS Data

set array[1].Number=AMC270
set array[1].Name=NB-34PTC63
set array[1].Name2=CALLIOPE
set array[1].Strumento=API 2000
set array[1].WorkstationName=RT4203ANALYST ... in dismiss
set array[1].Path=c$\SCIEX OS Data

:: Macchine che saranno traslocate
set array[2].Number=AMC281
set array[2].Name=WKSANAPOM06
set array[2].Name2=SOCHMACHER
set array[2].Strumento=API 4000QTRAP
set array[2].WorkstationName=WKSANAPOM06
set array[2].Path=c$\Analyst Data\Projects

set array[3].Number=AMC290
set array[3].Name=WKSANAPOM09
set array[3].Name2=MANFREDI 
set array[3].Strumento=API 4000
set array[3].WorkstationName=WKSANAPOM09
set array[3].Path=c$\Analyst Data\Projects

set array[4].Number=AMC374
set array[4].Name=WKSANAPOM07
set array[4].Name2=ULISSE	
set array[4].Strumento=API 5500
set array[4].WorkstationName=WKSANAPOM07
set array[4].Path=d$\Analyst Data\Projects

set array[5].Number=AMC402
set array[5].Name=WKSANAPOM08
set array[5].Name2=ITALO	
set array[5].Strumento=API 5600+
set array[5].WorkstationName=WKSANAPOM08
set array[5].Path=c$\Analyst Data\Projects

::ACQUISISCE LOCALMENTE  D:\Analyst Data\Projects
set array[6].Number=AMC433
set array[6].Name=WKSANAPOM10
set array[6].Name2=ULTIMO	
set array[6].Strumento=API 6600
set array[6].WorkstationName=WKSANAPOM10
set array[6].Path=c$\Analyst Data\Projects

:: Macchine gà nel nuovo laboratorio
set array[7].Number=AMC463
set array[7].Name=WKSANAPOM03
set array[7].Name2=EDDIE	
set array[7].Strumento=API 7500 
set array[7].WorkstationName=WKSANAPOM03 + WKSANAPOM04
set array[7].Path=c$\SCIEX OS Data

set array[8].Number=AMC465
set array[8].Name=WKSANAPOM01
set array[8].Name2=GIGI	
set array[8].Strumento=API 7500
set array[8].WorkstationName=WKSANAPOM01 + WKSANAPOM02
set array[8].Path=c$\SCIEX OS Data

set array[9].Number=AMC467
set array[9].Name=WKSANAPOM05
set array[9].Name2=BOND	
set array[9].Strumento=API 6600+
set array[9].WorkstationName=WKSANAPOM05
set array[9].Path=c$\SCIEX OS Data

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *