Link to home
Start Free TrialLog in
Avatar of Lee Yogel
Lee YogelFlag for United States of America

asked on

batch files Error

i created a batch file that goes and pulls data from a folder that is created on a daily basis in the following format
eg D20110429 within that folder are .pdfs that are copied to a local server.
The command line reads as follows:
cd Sierra Expidite\G148bc\web\reports\archive\D%date1%
I receive the following error:

It should drill down the the current date folder.folder presence was verified
The system cannot find the specified path.
The Syntex of the command is incorrect
I


Also within the same batch file I want to copy the above pdf data to a directory that has the days of the week

eg Monday batch files are created as .pdf in folder name D20110429 at location A
batch needs to pull all pdf info from D20110429 and copy it ti a corrisponding day of the week folder
 
I have attached the  batch file for review



 
rem ***Get current date into %date% variable without separators***
REM *** This determines the system date for Windows NT***
rem @echo off

for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
   set DayOfWeek=%%i
   set Month=%%j
   set Day=%%k
   set Year=%%l
   set Date=%%l-%%j-%%k-%%i
   set Date1=%%l%%j%%k
   set Date2=%%j
)



net use P: /d

Echo ****Copying reports for Bridesburg****

net use P: \\192.168.2.70\c$
p:
cd \Sierra Xpedite\G148BC\Web\Reports\Archive\D%date1%\
pause
copy *.pdf F:\Shared Files\Daily\Earth Star\Shared Directory\Shared\dailyin\*-Bridesburg.pdf

net use P: /d
pause

Echo ****Copying reports for Bridesburg Completed****

net use P: /d

Echo ****Copying reports for Pulaski****
net use P: \\192.168.4.70\c$
P:
cd \Sierra Xpedite\G148BC\Web\Reports\Archive\D%date1%\
copy *.* F:\Shared Files\Daily\Earth Star\Shared Directory\Shared\dailyin\*-Pulaski.pdf
f:
net use P: /d
Echo ****Copying reports for Pulaski Completed****
pause

Echo ****Copying reports for Torresdale****
net use P: \\192.168.5.70\c$
P:
cd \Sierra Xpedite\G148BC\Web\Reports\Archive\D%date1%\
copy *.pdf F:\Shared Files\Daily\Earth Star\Shared Directory\Shared\dailyin\*-Torresdale.pdf
f:
net use P: /d
Echo ****Copying reports for Torresdale Completed****


echo ****IT08****

Open in new window

Avatar of ReneGe
ReneGe
Flag of Canada image

Well, if the path you want to go is a sub-dir of the current path, theres a missing dot:
cd .\Sierra Xpedite\G148BC\Web\Reports\Archive\D%date1%

Better to put brackert to paths and filenames. In case you have spaces:
copy *.* "F:\Shared Files\Daily\Earth Star\Shared Directory\Shared\dailyin\*-Pulaski.pdf"

You can't "SET DATE" to something

Also, your date parsing is wrong. Use this instead and replace %date% to %TheDate% in your script.

REM READ DATE
FOR /F "skip=1 tokens=1-4" %%A IN ('WMIC Path Win32_LocalTime Get DayOfWeek^,Day^,Month^,Year /Format:table') DO (
	IF %%A GTR 0 (
	SET DayOfWeek=%%B
	SET Month=%%C
	SET Day=%%A
	SET Year=%%D
	)
)

SET TheDate=%Year%-%Month%-%Day%-%DayOfWeek%
SET Date1=%Year%%Month%%Day%
SET Date2=%Day%

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ReneGe
ReneGe
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad I could help