Copy from a cd specific file types to a new folder on a usb stick Windows

Welcome to Programming Tutorial official website. Today - we are going to cover how to solve / find the solution of this error Copy from a cd specific file types to a new folder on a usb stick Windows on this date .

Trying to make a batch file that will copy a specific file type from a CD and put it in a new folder with a prompt for choice of destination folder name. I’ve had a hard time explaining how to find files on a number of older users how to transfer files to a usb stick, so I’m hoping for a one double click answer.

I’ve tried a few variations of xcopy, but it didn’t have any output as far as I can tell.

D drive being the CD drive, and E being the usb drive. The files I’m searching for in the CD are buried through several folders deep.

Not attached to a batch file if there is a better way to do this. Thanks.

@echo off
set /p x= 
xcopy "D:" "E:%x%" .*pes /s

Tried running it from the E drive to simplify,

xcopy E: *.pes /s

It does copy, but it copies the entire directory… and makes all files into .pes instead of only copying the .pes now.

Answer

It should work like this:

@echo off
set /p x= 
xcopy "D:*.pes" "E:%x%" /s

But the folder structure of the source will also be created at the destination.

To copy all files in only one folder, this might get used:

@echo off
set /p x= 
for /r "D:" %%i in (*.pes) do xcopy "%%~fi" "E:%x%"

Edit to clarify/research:

FOR /R = recursive FOR loop (https://ss64.com/nt/for_r.html)

%%i = variable for every file

(*.pes) = every file in the folder / subfolders that ends with .pes

This doesn’t seem to be necessary: “%%~fi”

%%~fi = “expands %%i to a fully qualified path name” (See FOR /? in CMD)

It also seems to work like this:

for /r "D:" %%i in (*.pes) do xcopy "%%i" "E:%x%"