[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

batch files  Error

Posted on 2011-04-29
3
Medium Priority
?
311 Views
Last Modified: 2013-11-25
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

0
Comment
Question by:dynnd
  • 3
3 Comments
 
LVL 10

Expert Comment

by:ReneGe
ID: 35500934
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

0
 
LVL 10

Accepted Solution

by:
ReneGe earned 500 total points
ID: 35500946
Also, you can't put a star in a file name (*-Bridesburg.pdf):
copy *.pdf "F:\Shared Files\Daily\Earth Star\Shared Directory\Shared\dailyin\*-Bridesburg.pdf"

0
 
LVL 10

Expert Comment

by:ReneGe
ID: 35971856
Glad I could help
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are using Scrum Framework or another agile process, a retrospective may be part of it. Does your team perform retrospectives? Are you getting value from your retrospectives? I see a common anti-pattern when people conduct a retrospective f…
Learn how ViaSat reduced average response times for IT incidents from 10 minutes to 30 seconds.
Progress
Introduction to Processes

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question