Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
leonardo.amaral90
- Posts: 1
- Joined: 20 Nov 2013 10:32
#1
Post
by leonardo.amaral90 » 20 Nov 2013 10:38
I need to finish this code to automate my work, the code does just make a copy every day of the most current file to another server, the problem is that the cmd not understand this Command *.* like veryone else, he is understood as a name of a file
Code: Select all
@echo off
FOR /F "tokens=1,2,3 delims=/ " %%a in ("%DATE%") do (
set DIA=%%a
set MES=%%b
set ANO=%%c
)
set H=0%H%
set FORMATO=%MES%-%DIA%-%ANO%
echo Data Atual: %FORMATO%
echo .
echo .
echo Transferindo uma copia do Relatorio Consolidado a pasta CETEC12
echo .
xcopy "C:\Users\p692089\Dekstop\RELAT?RIO?CONSOLIDADO\11?-?NOVEMBRO\*.*" "C:\Users\p692089\Desktop\FINAL\" /D:%FORMATO% /U /Y
echo .
echo Transferindo uma copia do Relatorio Detalhado a pasta CETEC12
echo .
xcopy "C:\Users\p692089\Dekstop\RELAT?RIO?DETALHADO\11?-?NOVEMBRO\*.*" "C:\Users\p692089\Desktop\FINAL\" /D:%FORMATO% /U /Y
echo .
echo .
echo .
echo Transferencia realizada com sucesso.
pause
Please, help me a solve this problema ...
Thank you

-
AiroNG
- Posts: 46
- Joined: 17 Nov 2013 15:00
- Location: Germany
#2
Post
by AiroNG » 20 Nov 2013 11:30
are the "?" in your code on purpose? because characters like \ / : ? " < > | can't be used in filenames or foldernames
cmd does recognize *.* as wildcards
test:
Code: Select all
xcopy "D:\USB-Stick\tools\*.*" "D:\USB-Stick\test\" /y
output:
Code: Select all
D:\USB-Stick>xcopy "D:\USB-Stick\tools\*.*" "D:\USB-Stick\test\" /y
D:\USB-Stick\tools\file1.txt
D:\USB-Stick\tools\file2.txt
D:\USB-Stick\tools\file3.txt
D:\USB-Stick\tools\file4.bat
D:\USB-Stick\tools\file5.cmd
D:\USB-Stick\tools\file6.txt
D:\USB-Stick\tools\file7.ini
D:\USB-Stick\tools\file7.dat
D:\USB-Stick\tools\file8.txt
D:\USB-Stick\tools\file9.txt
10 File(s) copied
Take a closer look at the /u switch of xcopy
