need to copy the files not subfolder in bat

need to gather all the zip files inside the all folder then move the all zip files to another drive in bat.
so can u help me with the code???

i used /s its copying folder also. i dont need to copy folder. just files inside the folder i need to copy to destination.
i tried *-*. its copying all files. i need specific zip files in all folder.

code:
Mkdir "%BackupPath%\%programName%\%date:~4,2%%date:~7,2%%date:~12,2%"
xCopy "%ProgramPath%\%programName%\%datefile%\*.zip" "%BackupPath%\%programName%\%datefile%"
folder-issues.PNG
sasi vAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CompProbSolvCommented:
It would be helpful to see the rest of the BAT file.  For example, how are BackupPath, ProgramName, and DateFile getting set?

If you truly want to move the ZIP files (and not copy them) then use move instead of xcopy.

You are correct that if you use /s you'll get subdirectories (that's exactly the intent) and *.* will copy all files.  From what you are describing, *.zip is correct for the file specification.
0
sasi vAuthor Commented:
ya ok,,i will send the rest of the bat file code. i need a copy of the zip file in my local. so i need to use copy only..

yes, i need to copy only file(.zip) in each folder alone. its copying with folder. its any chance to copy files alone to the backup path??
SET ProgramPath=%CD%

SET BackupPath= ---- my copying drive---------
  dir /a =%BackupPath%\%programName%\ /b > filename1.txt
  setlocal EnableDelayedExpansion & time /T
  Date /T

    rem Initialize variables
    set OldestDate=999999
    set OldestFile=

    rem Read each line from list file
    for /f "usebackq tokens=*" %%A in ("filename1.txt") do (

        rem Get right 6 characters of file name and arrange in YYMMDD format
        set FileName=%%~nA
        set FileDate=!FileName:~-2!!FileName:~-6,4!

        rem See if this is the oldest file so far, if so save it
        if "!FileDate!" LSS "!OldestDate!" (
            set OldestDate=!FileDate!
            set OldestFile=%%~A
        )  )
    rem Delete the oldest file
    echo Deleting oldest file "%~1\%OldestFile%"
    del "filename1.txt"
Mkdir "%BackupPath%\%programName%\%date:~4,2%%date:~7,2%%date:~12,2%"
 xCopy  /x "%ProgramPath%\%programName%\%datefile%\*.zip" "%BackupPath%\%programName%\%datefile%"
  echo Zip Files Moved

pause
exit
0
CompProbSolvCommented:
It would be helpful to put a pause command on the line after the xcopy command and see what it is actually using for that command.  What is this doing that you don't want?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

sasi vAuthor Commented:
sorry, i didn't get you,, can u elaborate with the code?
x copy itself not copying files alone copying with folder.. that is the problem.
0
CompProbSolvCommented:
As the BAT file runs, it should display each line.  I'm wanting to know what it displays for the xcopy line.  If you put a line with just the word pause on it after that line it will stop there until you press a key.  You may be able to scroll up and see exactly what it was using for the xcopy line.

I'm not understanding "x copy itself not copying files alone copying with folder.. that is the problem."

Are the folders being created as you expect?

Is this really how the line reads?  SET BackupPath= ---- my copying drive---------

I don't see where CD, ProgramName, or DateFile get set to any value.

You create the folder: "%BackupPath%\%programName%\%date:~4,2%%date:~7,2%%date:~12,2%" but when you do the xcopy, the destination is: "%BackupPath%\%programName%\%datefile%"
I suspect that you need to replace the MkDir line with these two lines:
set datefile=%date:~4,2%%date:~7,2%%date:~12,2%
Mkdir "%BackupPath%\%programName%\%datefile%

With that change, xcopy will use the same destination as you just created.
0
sasi vAuthor Commented:
hi,

already directory is created i need to create a folder in that directory.
folder are crated as my expected, files copying with folder. need only to copy zip files alone.
for that i need a code.
while xcopy command, its copying along with folder. i need to copy only files. see the attached snap. i dont need that new folder . just zip files alone i need to copy to my backup path.
folder-issues.PNG
0
CompProbSolvCommented:
I suspect that the unassigned variables that I mentioned before may be the issue.
Again, letting me know what the xcopy line reads as when it executes would likely be very helpful.
0
sasi vAuthor Commented:
read my local folders is my source.

creating todays folder and doing my manual process then creating four folders and inside each folder zip is created, so i need to move all 4 zip files to destination.
0
CompProbSolvCommented:
If you'll provide the info requested in my earlier posts I can likely help.
0
sasi vAuthor Commented:
that only i informed you. other than what u need?

i explained what the xcopy reads and all sir
0
CompProbSolvCommented:
To repeat:
Are the folders being created as you expect?
Is this really how the line reads?  SET BackupPath= ---- my copying drive---------
I don't see where CD, ProgramName, or DateFile get set to any value.  (Implied question: where are they set?)
Again, letting me know what the xcopy line reads as when it executes would likely be very helpful.

If you think you've answered all of that, please repeat your answers for each of the lines above.
0
sasi vAuthor Commented:
Are the folders being created as you expect? yes created
SET BackupPath=\\ecc9000203\proj\DI_PMTI_SE\PAT\PAT\PATFiles
I don't see where CD, ProgramName, or DateFile get set to any value----  CD is current directory..
set dateFile=%mm%%dd%%yy%
echo off
SET programName=
SET /P programName=Enter program name :

SET ProgramPath=%CD%

SET BackupPath=\\ecc9000203\proj\DI_PMTI_SE\PAT\PAT\PATFiles

Xcopy reads folder and its files in my local and cupying to destination.

me need only files has to be copy. for that i need a code or solution
0
CompProbSolvCommented:
OK.... I missed the ProgramPath line but I don't see the others in the code you posted earlier.

Can you provide the actual xcopy line when it is executed?  That is, with all of the variables resolved.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Bat

From novice to tech pro — start learning today.