Solved

Copy files NOT folders from CD

Posted on 2004-11-01
862 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
Question by:boldnbrash73
    6 Comments
     
    LVL 6

    Accepted Solution

    by:
    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
    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 95

    Expert Comment

    by:Lee W, MVP
    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
     

    Author Comment

    by:boldnbrash73
    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
    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
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
    Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

    875 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now