Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copy files NOT folders from CD

Posted on 2004-11-01
6
Medium Priority
?
886 Views
Last Modified: 2008-03-17
I have 5 CD#s with perhaps 100 folders each containing thousands of  images and need to copy the images only to a folder on my C: drive called 'images' where they will be worked on.

At the moment I am using a command prompt to open each folder and then using Xcopy to copy and verify each file in its destination. The problem is that this is very time consuming as each folder takes about 10 minutes at which point I have to change directory and start the copy again.


What would be much better is a tool that enables copying of all files from the CD without copying the folders.

E.G.

The contents of d:\0b\*.* and d:\0c\*.* (plus the other 100 or so folders)

get copied to c:\images

Does anyone know of any utility (preferably free) that might help
0
Comment
Question by:boldnbrash73
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 6

Accepted Solution

by:
kapes earned 2000 total points
ID: 12462407
tell me ...

U don't want the folder structure to come with file copy... only files should be copied to c:\images..?

If yes and if Images extention are common then

do this...

Assume your cd rom drive letter =   Y
assume your images file extentions is = JPG

run this command

dir /a /s /b Y:\*.jpg > JPGfiles.txt
for /F "Tokens=1*" %%A in (JPGfiles.txt) do copy "%%A"  c:\images /y

It will first create list of all JPG files with full path to each file..
0
 
LVL 6

Expert Comment

by:kapes
ID: 12462440
You must put the above two command in a batch file then run

if you want to directly run from command prompt then

do this

dir /a /s /b Y:\*.jpg > JPGfiles.txt
for /F "Tokens=1*" %A in (JPGfiles.txt) do copy "%A" c:\images /y


0
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 12462738
kapes has an excellent solution.  One thing that _I_ would modify:

for /F "Tokens=1*" %A in ('dir /a /s /b Y:\*.jpg') do copy "%A" c:\images /y

No need for the seperate dir line.

Alternatively, run from the CD's root directory:
for /r y:\ %a in (.) do @copy %a\*.* c:\images /y

Note: any time you use for in a batch file, the %a must be %%a - outside of a batch file, it's just %a.  You can reference other system variables normally.
And just to take it a step further, this script should actually prompt you for the other CDs.  Also, my examples use the same assumption kapes' do.

---------------8<-------------------------
@echo off
Set /p rootdircopy=What is the root directory you are copying from?  For example - c:\temp:
set /p targetdir=What is the target directory you are copying to?
set /p cds=How many CDs?
:start
If %counter% gtr %cds% Goto End
for /r %rootdircopy% %%a in (.) do @copy %%a\*.* %targetdir% /y
set /a counter=%counter% + 1
Echo Please insert cd %cds% and
pause
:end
---------------8<-------------------------
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:boldnbrash73
ID: 12462924
I have had succes with kapes method but none with the script from leew. Although a batch file was my prefered method I can easily make one using the script examples from kapes.

With this in mind  a big thanks to leew but the full points go to kapes for providing an immediate working solution.
 Sorry but i have no time to debug your code with you leew, but here is what i used

@echo off
Set /p rootdircopy=d:\
set /p targetdir=c:\images\
set /p cds=4
:start
If %counter% gtr %cds% Goto End
for /r %rootdircopy% %%a in (.) do @copy %%a\*.* %targetdir% /y
set /a counter=%counter% + 1
Echo Please insert cd %cds% and
pause
:end

0
 
LVL 6

Expert Comment

by:kapes
ID: 12463199
Also... During testing i found that...it won't copy if file path contains the spaces so ...

This is the updated line....(it will take care of spaces in the file path)...

for /f "Tokens=1* Delims=*" %A in ('dir /a /b /s y:\*.jpg') do copy "%A" c:\images /y


0
 
LVL 6

Expert Comment

by:kapes
ID: 12463528
changes to leew's  Script...
He assumes that you want to copy every file available and not only images...

* Counter was not set beforehand (not a major issue but better to do it...)
* he assumes your working directory will be SOURCE DIR and starts from there...
* Not looping back to START

---------------8<-------------------------
@echo off
Set /p rootdircopy=What is the root directory you are copying from?  For example - c:\temp:
set /p targetdir=What is the target directory you are copying to?
set /p cds=How many CDs?
set counter=1
:start
:: Next line will set wroking directory as %rootdircopy%
cd /D %rootdircopy%
If %counter% gtr %cds% Goto End
for /r %rootdircopy% %%a in (.) do @copy %%a\*.* %targetdir% /y
set /a counter=%counter% + 1
Echo Please insert cd %cds%
pause
:: next line will go back to START and run the loop again...
goto start
:end
---------------8<-------------------------


if you  want to copy more than... one extension...
e.g. Say provide a list of extension with semicolon (;) separating each value in a variable
use for loop to separate them and loop the it in the above script..

Try that for a scripting practice..
if u need help.. just buzz me..
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question