I have 10 folders, each folder contains one excel file. How to copy all 10 files using command function using bat file?
1
this loop through your “parent_folder_path” including subfolders for excel files, and copy each one to your “destination_folder_path”
for /f "tokens=*" %a in ('where /R "parent_folder_path" *.xlsx') do copy "%%a" "destination_folter_path"
A simple recursive loop over *.xlsx files and copy them is sufficient here:
for /r "P:arent Folder" %%a in (*.xlsx) do copy "%%a" "D:estination Folder"
Adapt the file mask *.xlsx
to your needs (maybe *.xls*
, or (several masks are possible) *.xlsm *.xlt*
There are reasons to use ? for /f
with ('where...
or ('dir...
, but none of them applies here.
3