batch files  Error

Posted on 2011-04-29
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

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: \\\c$
cd \Sierra Xpedite\G148BC\Web\Reports\Archive\D%date1%\
copy *.pdf F:\Shared Files\Daily\Earth Star\Shared Directory\Shared\dailyin\*-Bridesburg.pdf

net use P: /d

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

net use P: /d

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

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

echo ****IT08****

Open in new window

Question by:dynnd
    LVL 10

    Expert Comment

    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.

    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

    LVL 10

    Accepted Solution

    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"

    LVL 10

    Expert Comment

    Glad I could help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    I worked at a US software company that used offshore contractors for ten years and offshore employees for three years. We had a positive experience and you can too.   When I interviewed people for positions in the US, I would tell them that we wor…
    Online collaboration can help businesses be more efficient, help employees grow their skills and foster a team environment.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video discusses moving either the default database or any database to a new volume.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now