Best way to find and copy files

If i have a list of 2000 file names and want to find:
if they exist in folder x
then copy to folder y
else
output an error messege to txt file.
What would the most efficient way to do this be? So far i've used listFiles() and put a >HUGE< directory listing into an Array. Then I did a comparison for each file name in the list against the array. I know this cant be the most efficient way. I posted earlier in the board but for some reason NO one answered. Can anyone suggest and easier way to do this? and what is the best way to copy files in java? opening a bufferwriter etc? Essectially, im doing a restore from multiple backup directories to the original directory. Please help me if you can take the time.
Thank you,
jon

If i have a list of 2000 file names and want to
find:
if they exist in folder x
then copy to folder y
else
output an error messege to txt file.
What would the most efficient way to do this be?In a loop just read and write each file. If it does not exist, print an error.
So far i've used listFiles() and put a >HUGE< directory listing into an Array. A directory with a million entries is a HUGE directory, I guess you only have a few thousand.
I wouldn't bother reading the files into memory, you only need 2000 of them.
Then I did a comparison for each file name in the list against the array. The OS will do this for you when you try to open the file, which you will have to do anyway to copy it.
I know this cant be the most efficient way. More efficient way, don't do it at all.
I posted earlier in the board but for some reason NO one answered. Perhaps the problem seemed too obvious.
Can anyone suggest and easier way to do this?
and what is the best way to copy files in java? Copy one at a time.
opening a bufferwriter etc? Read a block of say 64K at a time. No buffers required.
Essectially, im
doing a restore from multiple backup directories to
the original directory. Please help me if you can
take the time.If you are recovering from a backup, the most important thing is ensuring the data is correct and valid, speed is less important. (It is no good if it is fast but corrupt)
Coping 2000 files is going to be only as fast as your drive(s) can handle. How you copy the file is less important.

Similar Messages

  • There are way too many photos on my internal hard drive. I have older libraries, and newer libraires in iPhoto and Aperture 2.  What is the best way to find and reduce the number of duplicate photos/libraries  before upgrading to Aperture 3?

    There are way too many photos on my internal hard drive. I have older libraries, and newer libraires in iPhoto and Aperture 2.  What is the best way to find and reduce the number of duplicate photos/libraries  before upgrading to Aperture 3?

    Sharon-
    Good idea.
    Back up first.
    I would probably wait for the merge function of the latest version before merging. Be sure to verify every merge.
    Merge Libraries, then from within Aperture move images to referenced on external hard drives.
    HTH
    -Allen

  • Aborting index build. Too many errors with finding and copying files ...

    Hi dears,
    I'm using UCM 11g.
    I'm trying to start the automatic update cycle. When i start it, it gives me an error message just like :
    Indexing aborted at :<time>. Aborting index build. Too many errors with finding and copying files to the appropriate place.+
    Can anybody help me about this problem?
    Helps will be appreciated.
    Erdo
    Edited by: erdo on 28.Mar.2013 11:11

    Read this: error in Collection Rebuild Cycle
    and maybe also UCM Indexer - Collection Rebuild Cycle errorring out

  • What is the best way to find and apply the samples in the sap library

    I am a fresh man in the process of learning sap .
    Mainly aim at the MM and SD model .
    They all say that the best way to accomplish the task is to follow the sap on-line help.
    because i don`t know the struts of the library , so to find what i need in the library becomes impossible for me as the library includes a lot of files .
    so please some one help me to direct the struts of the library and teach me the way how to find what i want ?
    thanks

    Hi,
    This forum is for BPX. Post Solution related quries in SAP Solution Forums.
    You can access MM and SD help at:
    http://help.sap.com/erp2005_ehp_02/helpdata/en/80/ea89395eb58c4f9d0c3e837cf0909d/frameset.htm under Logistics
    or http://help.sap.com/ -> SAP ERP -> Choose Release (for example SAP enhancement package 2 for SAP ERP 6.0) -> SAP ERP Central Compoennt (MM and SD under Logistics)
    From Materials Management Link you can navigate further to Purchasing, Inventory Management etc. From Sales and Distribution you can naviate further: Sales, Billing etc.
    For example to see help regarding Purchase Orders:
    You would first expand Logistics and choose Materials Management in Help Link for ERP Central Component. Here, choose Purchasing Node which will take you Purchasing Help screen -> Click and Purchase Orders Node and Expand the same for more information regarding Purchase Orders.
    You should be comfortable with SAP help link.
    Regards,
    Naveen.
    Search the forum with keywords before posting the query.

  • Find and copy files by file name

    Hey Gang,
    I sure hope you guys can help me out. I'm looking for a piece of software that can read a txt file or spreadsheet to find specific files and copy them from one place to another.
    In other words, I have a folder with 1000 files in numerical order from 1 to 1000. I need software that can copy only selected images (ie 4, 53, 244, 456, 999, etc...) to a separate folder.
    Any Ideas?
    -Chris

    This is very simple to do with a script.
    Let's assume that the files are in /Users/cnhoward/source and you want to move particular files to /Users/cnhoward/dest. Let's say you have a text file, numbers.txt, with one number on each line, and the files are named like 'file_X.txt' where 'X' is the number. Then you could do this in terminal:
    for n in `cat numbers.txt`
    do
    cp /Users/cnhoward/source/file_${n}.txt /Users/cnhoward/dest
    done
    You don't give much in the way of details, but that should give you an idea to start from.

  • Best way to validate and xml file against a schema?

    As the subject states, I want to validate my xml file against a given schema....
    Currently my code looks like this:
    InputSource ipSource = new InputSource(new ByteArrayInputStream(bytesData)); // my xml file
    DOMParser parser = new DOMParser();
    parser.parse(ipSource);
    Document doc = parser.getDocument();
    I see that there is a setFeature method on DomParser.... but from what I read that doesnt support
    xml schema's, just DTD's. So what is the best way to validate with schema's?
    Any help would be appreciated

    This is the other way I tried doing it.... the problem with this way is I am building my xml file through DOM
    operations... and I haven't figured out how to add the schema line to the xml file through DOM manipulations.
    Has anyone done this bofore?
    try
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setNamespaceAware(false);
         factory.setValidating(true);
         InputSource ipSource = new InputSource(new ByteArrayInputStream(bytesData));
         DocumentBuilder builder = factory.newDocumentBuilder();
         doc      = builder.parse(ipSource);
         return doc;
    catch(Throwable t)
         System.out.println("parse error: " +t);
    return doc;
    }

  • What is the best way to find and remove unneeded language files from Mac OS X 10.8.4?

    I have tried Spring Cleaning and it finds the files and then quits!

    You can do this with a *FREE* utility called Monolingual.  Another app that apparently does all the work for you.  I’ve used it since Tiger w/never any problems.  Just make sure you read all of the instructions.
    However, there is a warning for *native English speakers*. Make sure you keep BOTH English and English (United States).
    Works on OS X 10.8 (Mountain Lion)

  • What is the best way to save and copy high resolution slide show?

    Creating and saving/burning slide shows in iMovie or iDVD does not appear to give the same high resolution as playing slide shows directly from iPhoto.  Resolution is also lost when exporting the slide show to iTunes.  Is there a recommended technique to preserve resolution when saving a slide show?

    Click the "Export" icon on the bottom of the application window.
    Click the "Custom Export..." button on the bottom left hand side of the new menu that appears at the top of the application window.
    At the bottom of the next window click the "Options..." button.
    Under the "Video" setting, click the "Size..." button.
    Next to "Dimensions:" click the "Compressor native" drop down menu.
    In there you have "1920 x 1080 HD".
    There are a bunch of other options, so explore and find what works best for you.

  • Best way to access and share files...

    I have all my files in a folder currently in Macintosh HD > Shared Items > Folder Name... Should I be changing this and adding the folder into my group folders?

    Which image or file or document or content management system depends highly on your specific local requirements and users, what sort of information you're storing and retrieving and indexing and updating (images, documents, something else) and what your budget is.
    [Here|http://en.wikipedia.org/wiki/Contentmanagementsystem] and [here|http://en.wikipedia.org/wiki/Documentmanagementsystem] are general introductions, and with links in various directions.
    Depending on what you're doing, other examples can re-purposed source code control packages include Mercurial (Hg) and git.

  • What is the best way to find the size of files?

    What is the best way to find the size of my files?

    Select a file or folder in the Finder and choose Get Info from the File menu.
    (125056)

  • Best way to view and edit OpenOffice files on my new iPad Mini (originally Word and Excel files). Thanks!

    Can someone tell me the best way to view and edit OpenOffice files on my new iPad Mini (originally Word and Excel files)? Thanks!

    wmf files is a MS Windows video file, you will need a tool to covert the wmf files to another file format OS X will read. Simply Google to find a converter you are interested in and use it.

  • How is the best way to backup and organize Adobe layered .PSD files on iMac OSX maverick?

    How is the best way to organize and backup Adobe layered PSD files on iMac desktop OSX maverick?
    I lost all my Adobe Photoshop files + everything else on my IMAC when it crashed. They reinstalled Operating System.  But now i must install programs such as MS Word & Adobe indesign suite.
    Please help me determine what is the bestway to backup Adobe layered  PSD files? I believe these are my choices to be assured this doesn't ever hapen again. Please comment.
    Buy Apple Airport Time capsule $280.  But I am not sure if it can store PSD layers. Can it or do you have to have Apple Apperture  software to act be sure layers are saved
    I had had trouble getting Adobe Cloud to sync to save files and so just trusted my computer to not ever crash.  Any hints on this procedure
    Are there any hints on PhotoShop image organization for a current IMac usser ?
    Please help.
    Teann  ucreateit

    My backup plan is to use Time Machine to make a backup to an external disk drive plus I also do a clone of my system disk. So far between the bootable clone and the Time Machine backup this plan has covered all of my needs.
    Allan

  • Is there a way to find and replace prices in an Indesign document from a CSV file?

    Is there a way to find and replace prices in an Indesign document from a CSV file. Currenty I have a catalog with codes and prices in tables. I need to find a way to look up the code (and new price) in the CSV file and overwrite the price in the current table with the new price. Does anyone know of a script to run this quickly?

    Hi,
    Try this
    1) with all the images showing, got to Find -> By caption or Note
    2) enter the caption you are looking for Image Description and click on OK
    It should display all the ones with that caption
    3) select a few images as a test
    4) go to Edit -> Add caption to selected items
    5) if you want to blank out the captions just check the box to replace the caption and click on ok
    6) You will need to confirm the blank captions
    You could use a similar procedure to change the caption to something else.
    Good luck
    Brian

  • What is the best way to find a file on the servers disk without using web.xml?

              What is the best way to find a file on the servers disk without using web.xml?
              I want to find a configuration file not contained within the war file I have
              created. Is there a way to pass information into the ServletContext with out
              rebuilding the ear or war files? Tomcat 4.0 can do this in its server configuration
              files. Does BEA have the equivalent?
              Regards,
              Eric
              

    You can specify the path to the file as a system property
              eg
              java -Dconfig.file.location=./mydirecotry/myfile.txt com.test.MyApp
              "Eric White" <[email protected]> wrote in message
              news:[email protected]..
              >
              > What is the best way to find a file on the servers disk without using
              web.xml?
              > I want to find a configuration file not contained within the war file I
              have
              > created. Is there a way to pass information into the ServletContext with
              out
              > rebuilding the ear or war files? Tomcat 4.0 can do this in its server
              configuration
              > files. Does BEA have the equivalent?
              >
              > Regards,
              > Eric
              

  • What is the best way to get a copy of Final Cut 7?  I don't see it on Apple's site anymore and I was told I needed to get ahold of Apple's Pro Divison?

    What's the best way to get a copy of Final Cut 7?

    Amazon.
    Apple stoped selling it officially 20 months ago.

Maybe you are looking for