user2220670
user2220670

Reputation: 125

Batch copy command doesn't reach subfolder

I have a batch command to copy and move file with a new name to another directory. When I added one more level of subfolder it does not copy but when I remove the added subfolder and move the file to the previous level it does copy. Here is it is:

cd /d dir "U:\Sourcing\Vendor Demand Planning\Customer CPFR\BBM\"

for /f "delims=" %%I in ('dir /b /o:-d "BBM Tool *.xlsx"') do (
    copy "%%I" "..\Pricing Project\BBM Tool.xlsx"
    exit /b
)

If I removed the BBM level and move the file into the Customer CPFR level it works. I edited this batch from another one that had the target file in the CPFR folder. The file I need to copy is in the BBM folder.

Upvotes: 0

Views: 154

Answers (2)

Magoo
Magoo

Reputation: 80033

I'd say that the "Pricing Project" directory is on the same level as "Customer CPFR" hence the target of the copy should be "..\..\Pricing Project...


(later edit)

Also dir in the CD line should be removed.

Upvotes: 0

RGuggisberg
RGuggisberg

Reputation: 4750

Change COPY to XCOPY and use /S

See XCOPY /?

Upvotes: 1

Related Questions