I try to access some Excel data stored on a server and copy these files to another server ; the destination path should be different with the name of the file. Here is my code :
setlocal enabledelayedexpansion
net use Z: \\10.0.0.1\Statistiques
set path=Z:\
set year=%date:~10,4%
set month=%date:~4,2%
set day=%date:~7,2%
echo %date%
for /f "delims=" %%a in ('dir *.xlsx /b /a-d "%path%" ') do (
set "name=%%~na"
set folder=Empty
if "!name!"=="!name:Client1=!" (
set folder=Client1
)
if "!name!"=="!name:Client2=!" (
set folder=Client2
)
copy "%path%%%a" "\\10.0.0.2\Documents\Statistiques\!folder!\%year%%month%%day%_!name!%%~xa"
)
net use Z: /delete
My issue is that the last 'net' is not recognized as an internal or external command, operable program or batch file.
On the first net use, the drive is correctly mount ; the files are correctly copied, but when I want remove the drive I have this error.
May be an error in my if () statement ?
Aucun commentaire:
Enregistrer un commentaire