HI dostips Batch Scripter Experts!!
urgently need a script that can read files from the reference text document &
copy the files from a folder through subfolders to the desire folder according to their filetype and will display message when done copying!!
for example, in my c: drive
c:\source\temp\fizzy moon.bmp
c:\source\temp\documents\jan_reports.doc
c:\source\temp\album\malesinger\usher 01.mp3
ref.txt
-----------------content-------------
fizzy moon
jan_reports
usher 01
---------------content end-----------
d:\destination\pictures\fizzy moon.bmp
d:\destination\work\jan_reports.doc
d:\destination\favourite\album\usher 01.mp3
Can bat scripts determine the filetype while getting all the filenames
from the ref.txt(in desktop) & copy them to their desire folders??
if possible, show a message displaying the copy process is done!!
thanks in advance, below is the script i done but it is not working...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@echo off
cd /d "%USERPROFILE%\DESKTOP\"
for /f "usebackq delims=" %%a in ('findstr /I /X /g:ref.txt') do xcopy %%~a *.bmp "d:\destination\pictures\"
for /f "usebackq delims=" %%b in ('findstr /I /X /g:ref.txt') do xcopy %%~b *.doc "d:\destination\work\"
for /f "usebackq delims=" %%c in ('findstr /I /X /g:ref.txt') do xcopy %%~c *.mp3 "d:\destination\favourite\album\"
dir /s /b "d:\destination\"*.*>list.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
really need some guides here, why isn't it working?!?
copy to desire folders as from text references
Moderator: DosItHelp
Re: copy to desire folders as from text references
Because the wrong syntax. Use the /? for help on command.
Code: Select all
@echo off
setlocal enableextensions
set "source=c:\source\temp"
set "destination=d:\destination"
cd /d %USERPROFILE%\Desktop
for /f "usebackq delims=" %%a in ("ref.txt") do (
if exist "%source%\%%~a.bmp" xcopy "%source%\%%~a.bmp" "%destination%\pictures"
if exist "%source%\%%~a.doc" xcopy "%source%\%%~a.doc" "%destination%\work"
if exist "%source%\%%~a.mp3" xcopy "%source%\%%~a.mp3" "%destination%\favourite\album"
)
dir /s /b "d:\destination">list.txt
start list.txt
Re: copy to desire folders as from text references
hi !k thanks for your help but
the scripts is not working!!!
the scripts looks like coudn't search through the subfolders for the files &
list out nothing copied..
this scripts works on you right?
i wonder why it isn't working in my pc?!?!
any further suggestion? Thanks
the scripts is not working!!!
the scripts looks like coudn't search through the subfolders for the files &
list out nothing copied..
this scripts works on you right?
i wonder why it isn't working in my pc?!?!
any further suggestion? Thanks
Re: copy to desire folders as from text references
Oh, sorry, you have the files in subdirectories
This is my inattention. Need to modify batch.
c:\source\temp\documents\jan_reports.doc
c:\source\temp\album\malesinger\usher 01.mp3
This is my inattention. Need to modify batch.
Re: copy to desire folders as from text references
Code: Select all
@echo off
setlocal enableextensions
set "source=c:\source\temp"
set "destination=d:\destination"
cd /d %USERPROFILE%\Desktop
for /f "usebackq delims=" %%a in ("ref.txt") do (
pushd "%source%"
for /f "usebackq delims=" %%b in (`dir /s /b /a-d "%%~a.*"`) do (
if "%%~xb"==".bmp" echo d|xcopy "%%~b" "%destination%\pictures"
if "%%~xb"==".doc" echo d|xcopy "%%~b" "%destination%\work"
if "%%~xb"==".mp3" echo d|xcopy "%%~b" "%destination%\favourite\album"
)
)
popd
dir /s /b /a-d "%destination%">list.txt
start list.txt