Copy files from locations listed in file

November 25, 2010 at 12:53:15
Specs: Windows 7
Hi, i would like to have a script which look for a folder with choosen name and then copy all files from found folders. Now I have some code, but it doesn't copy files from paths in found.txt file, but paths are inside. Can anyone help me?

@echo on & setlocal enableextensions
cd\
set /P found="Set folder name: "
dir c:\Users\Bazook /S /B /A:D |find /I "%found%">>found.txt
for /F “delims=” %%path in ("e:\found.txt") do (xcopy "%%path\*.*" /e)


EDIT:
I have success with code:

@echo on & setlocal enableextensions
cd\
set found=src
dir c:\Users\Bazook /S /B /A:D |find /I "%found%">>found.txt
if not exist E:\directory\ md E:\directory
for /f "tokens=*" %%a in (e:\found.txt) do xcopy /Y/E "%%a" E:\directory
del found.txt

But now is other problem. Every file is in E:\directory or in subfolder thanks /E argument but I dont know which was with which other in one ../src folder. Is some possibility to make sth like this: files from first found src folder will be copied into src1, files from second found src folder will be copied into src2...? Or better if src was in eg. C:\some_dir\src then it files will be copied into E:\directory\some_dir\src.


See More: Copy files from locations listed in file

Report •


#1
November 26, 2010 at 11:01:58
@echo off & setLocal EnableDELAYedeXpansion

set /p F=folder ?

for /f "tokens=* delims= " %%a in ('dir/b/s/a-d !F!') do (
copy "%%a" d:\dest
)


=====================================
Life is too important to be taken seriously.

M2


Report •
Related Solutions


Ask Question