Copying files that are updated.

I wanted to make a program that copies files from a directory (and subdirectories) to another location.
So let's say I have a folder in C:\myfolder . In this folder there is another folder (myfolder2) and some type of file(s) (.txt .docx etc.). In myfolder2 there are/is some file(s) also.
I want this program to check each and every FILE if it is older than a FILE in some other location (C:\myotherfolder). If the file does not exist in myotherfolder then it should copy it also.
So the question is: Does someone know a good and effective way of copying ONLY the files that are "new" but leave the others alone AND reach into as many subdirectories as possible.
Here is an effort in doing this but I have stopped since I'm afraid that this would require me to make alot of if statements if there are many subfolders:
import java.io.File;
* @author Simmi
* @version 15.sept.2009
public class CompareFiles
    // instance variables - replace the example below with your own
    private String f1;    // The location to be copied.
    private String f2;      // The location to copy to.
    private String files[];    
    private String files2[];
    private String relation;  // Not used at the moment.
    private long d1;    // Not used at the moment. Going to be used to compare the date of two files.
    private long d2;    // Not used at the moment. Going to be used to compare the date of two files.
     * Constructor for objects of class CompareFiles
    public CompareFiles(String f1,String f2)
        this.f1 = f1;
        this.f2 = f2;
        initialize();
    public void compare()
    public void printDetails()
    private void initialize()
        File src = new File(f1);
        String files[] = src.list();   // Not sure if this is a good way.
        File dst = new File(f2);
        String files2[] = dst.list();    // Not sure if this is a good way.
        if(src.isDirectory())
        if(!dst.exists())
            dst.mkdir();
            for(String string : files)
                File myfile = new File(f1,string);
                if(myfile.isDirectory())        //  Here I halted.
                System.out.println(string.toString());   //  Only to test if all the files are there.
}

This lists the files on your C Drive. You may want to change where it starts or at least run it in your IDE so you can stop it.
import java.io.File;
import java.io.IOException;
public class ForumJunk {
  public ForumJunk(){
    File f = new File("C:/");
    listDirContents(f.listFiles());
  public void listDirContents(File[] s){
    for(int i=0; i<s.length; i++){
      if(s.isDirectory()) listDirContents(s[i].listFiles()); //recurse
try{
System.out.println(s[i].getCanonicalPath());
}catch(IOException e){
System.out.println(e.toString());
public static void main(String[] args) {
new ForumJunk();

Similar Messages

  • Itunes is copying/converting 500gb of music from .wma to .m4a files that are on an external drive onto my laptop which doesnt have enough room. how do i reroute these newly converted files somewhere with enough space for them?

    itunes is copying/converting 500gb of music from .wma to .m4a files that are on an external drive onto my laptop which doesnt have enough room. how do i reroute these newly converted files somewhere with enough space for them?
    new to itunes, used windows media player before that and always ripped music directly to an external hardrive and accessed it through the player. now that i downloaded itunes it is taking from the external hardrive and copying a second file for each song onto my lap top hard drive which does not have the capacity for all my music. as itunes converts music files i want them saved back onto my external drive or another location i have space for rather than the lap top. how do i change the setting to move the itunes media folder to another location. assuming that hitting copy and past and dropping it in a random location will cause a few errors.

    When I have done this, all I did was network the two machines and copy the contents of the iTunes folder to the other machine, and that's it.
    My understanding (which may not be 100% correct) is that the one file that is absolutely necessary is iTunes Library, and that the XML file is actually a copy auto-generated from the iTunes Library, appearing in a different format only for non-iTunes apps that take advantage of the iTunes Library data.
    As far as I know, if you simply have the Library (database) file and all your original music files, iTunes on that computer should operate as it did on your old computer. I believe that the Album Artwork, Genius Data, and XML files can be regenerated from the Library file. Not sure about the Extras file.

  • Ipod cannot be updated because it contains files that are in use by an

    My fifth gen/30 ipod is a mess since I installed itunes 7.I can't update or eject the little guy .The message reads"cannot be updated because it contains files that are in use by another application"or "cannot be ejected because it contains files that are in use by another application" Any help would be very appreciated!
    Thanks!
    dell   Windows XP   30 gb video

    I had the same problem. I had to uninstall 7.0 and install 6.0 and was able to restore OK. I'm back using 6.0, but just got a second generation ipod nano, so I have to go to 7.0 or greater. My only words of wisdom are DO NOT SET ANY LOCKS until you are really sure you want to. Also with 7.0 I could not eject my ipod unless I went to the "safe to eject ipod" command. Apple has some problems to work out and I hope soon. Clumsy as best...............
    Dell Demension 8100 Desk Top   Windows XP  

  • Cannot update ipod due to files that are in use by another application

    Uploaded iTunes version 7 onto my PC on Friday. Ever since my fifth generation video (30GB) ipod cannot be either updated with version 1.2 software, syncronised or restored due to the error message "The ipod cannot be updated becuase it contains files that are in use by another application".
    Not sure the issue is related to the itunes upgrade but it is a strange coincidence.
    Also having a problem becuase my pc runs outlook 2002 which is not compatible with itunes 7 and my calender cannot be syncronised. Don't know whether the two issues are related.

    Kudos to Randy. Thanks a lot; this worked for me. I simply opened itunes (and minimized it) with my ipod connected, opened "My Computer," right-clicked "IPOD" and ejected it. As soon as the icon in My Computer showed that it was ejected I quickly maximized itunes, clicked IPOD, and clicked the update button. Wah lah! iPod updated. Hope that helps the rest of you out there with this problem! Thanks again!
      Windows XP  

  • What happened is that my internet connection was not good so i downloaded .ipsw file from a torrent but now i cannot get it to update my ipad because ios 5.0.1 is out i tried copying files to ipad updates in the itunes folder but no help

    what happened is that my internet connection was not good so i downloaded .ipsw file from a torrent but now i cannot get it to update my ipad because ios 5.0.1 is out i tried copying files to ipad updates in the itunes folder but it still asked me to download a 700mb software update
    plz help

    If you downloaded the correct version for your iPad model (and the different models have different ipsw files), then you should be able to navigate to it in iTunes by pressing and holding the shift key on Windows (command key on Mac) when clicking the Check For Updates button.
    Message was edited by: King_Penguin

  • SAFARI 6.1.3 update to Reader 11.0.07 - cannot open pdf files that are presently on my computer. Previous version had no problem. Any ideas?

    SAFARI 6.1.3 update to Reader 11.0.07 … cannot open pdf files that are presently on my computer. Previous version had no problem. Any ideas? (Here is the message: Adobe Reader could not open 'Digital_Holiday_Cookbook.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).

    Thank you Pat!!!
    Craig Ekonomos
    [email address removed]

  • [svn] 670: -major update to the mpl packaging target - this will now package up the correct files that are mpl

    Revision: 670
    Author: [email protected]
    Date: 2008-02-26 18:14:40 -0800 (Tue, 26 Feb 2008)
    Log Message:
    -major update to the mpl packaging target - this will now package up the correct files that are mpl
    -this target is not called within this build script. to build this pkg use: ant mpl-package
    Modified Paths:
    flex/sdk/branches/3.0.x/build.xml

    One small thing - I believe the reason why some of my drivers were messing up was because they were SP2 specific; the older drivers and the ones that were compatible with both SP and 2 were fine.
    As soon as I did the reinstall, all of the drivers/programs that were not working, worked (aside from the ones that I mentioned in my attached email above).
    So, if after uninstalling the old SP2 you are told that loads of drivers/programs will not work, fear not - most should fix themselves upon installing the new SP2.
    G

  • On Windows 7, neither my quicktime or iTunes will start. This started after I installed the newest update. All the files that are needed are there. I recently updated Quicktime to see if that would work, but it didn't.

    This started after I installed the newest update. All the files that are needed are there. I just updated Quicktime to see if that would work, but it didn't. I looked through some other discussions like this, and found out that all of my files are correct. Some people are saying that they needed to remove Filebot, but I can't find that on my computer. Help, please?

    This started after I installed the newest update. All the files that are needed are there. I just updated Quicktime to see if that would work, but it didn't. I looked through some other discussions like this, and found out that all of my files are correct. Some people are saying that they needed to remove Filebot, but I can't find that on my computer. Help, please?

  • I recently purchased the newest nano. I have 3 other nano's and iPad   iPhone, oh and iPod touch. When I plug in nano to my mac I get the message "iPod cannot update because it contains files that are used by another application. How can manage this?

    I recently purchased the newest nano. I have 3 other nano's and iPad   iPhone, oh and iPod touch. When I plug in nano to my mac I get the message "iPod cannot update because it contains files that are used by another application. How can manage this?

    dedonred wrote:
    "iPod cannot update because it contains files that are used by another application.
    It means that nano was used on a third-party software or synced from different computer to sync music. Does that nano show in iTunes? If yes, then restore completely. If not, then you may need to head to Apple Store and see what they can do.

  • How do I erase the "other" files that are occupying my computer

    I already deleted pics, music, etc and I am ready to continue to delete unnecessary files. How should I erase the "other" files that are in my computer. Please, advice. Thanks

    For information about the Other category in the Storage display, see this support article. If the Storage display seems to be inaccurate, try rebuilding the Spotlight index.
    Empty the Trash if you haven't already done so. If you use iPhoto, empty its internal Trash first:
              iPhoto ▹ Empty Trash
    Do the same in other applications, such as Aperture, that have an internal Trash feature. Then restart the computer. That will temporarily free up some space.
    According to Apple documentation, you need at least 9 GB of available space on the startup volume (as shown in the Finder Info window) for normal operation—not the mythical 10%, 15%, or any other percentage. You also need enough space left over to allow for growth of the data. There is little or no performance advantage to having more available space than the minimum Apple recommends. Available storage space that you'll never use is wasted space.
    See this support article for some simple ways to free up storage space.
    You can more effectively use a tool such as OmniDiskSweeper (ODS) or GrandPerspective (GP) to explore the volume and find out what's taking up the space. You can also delete files with it, but don't do that unless you're sure that you know what you're deleting and that all data is safely backed up. That means you have multiple backups, not just one. Note that ODS only works with OS X 10.8 or later. If you're running an older OS version, use GP.
    Deleting files inside an iPhoto or Aperture library will corrupt the library. Any changes to a photo library must be made from within the application that created it. The same goes for Mail files.
    Proceed further only if the problem isn't solved by the above steps.
    ODS or GP can't see the whole filesystem when you run it just by double-clicking; it only sees files that you have permission to read. To see everything, you have to run it as root.
    Back up all data now.
    If you have more than one user account, make sure you're logged in as an administrator. The administrator account is the one that was created automatically when you first set up the computer.
    Install the app you downloaded in the Applications folder as usual. Quit it if it's running.
    Triple-click anywhere in the corresponding line of text below on this page to select it, then copy the selected text to the Clipboard by pressing the key combination command-C:
    sudo /Applications/OmniDiskSweeper.app/Contents/MacOS/OmniDiskSweeper
    sudo /Applications/GrandPerspective.app/Contents/MacOS/GrandPerspective
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window by pressing command-V. You'll be prompted for your login password, which won't be displayed when you type it. Type carefully and then press return. You may get a one-time warning to be careful. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. Ignore any other messages that appear in the Terminal window.
    The application window will open, eventually showing all files in all folders, sorted by size. It may take a few minutes for the app to finish scanning.
    I don't recommend that you make a habit of doing this. Don't delete anything as root. If something needs to be deleted, make sure you know what it is and how it got there, and then delete it by other, safer, means. When in doubt, leave it alone or ask for guidance.
    When you're done with the app, quit it and also quit Terminal.

  • I cannot ope PDF files that are within a web link.  Neither Safari nor Firefox will work.  If I receive a PDF file as an email attachment, I can open it with either Adobe or Preview.  I'm running 10.6.8 on an iMac.

    I'm going to re-state this.  Several weeks ago, I had installed Security Update 2012-004 on my iMac.  I'm running Snow Leopard 10.6.8.  Immediately afterwards, my Mail 4.6 was GONE.  Mail 4.2 was there, but the system would not open it.  The Apple Support Communites quickly solved my problem.  The problem lay within the Update.  Now, I cannot open PDF files that are contained within a website, i.e. a lunch menu that is on a restaurant website.  This happens on both Safari and Firefox.  If someone sends me an email with an attached PDF file, I can open the file with either Adobe or Preview.  This is happening only on my iMac.  My MacBook Pro, also running Snow Leopard 10.6.8 has not experienced either the first or second problem.  Thanks for any help you can offer.

    fomamac2guy wrote:
    Now, I cannot open PDF files that are contained within a website, i.e. a lunch menu that is on a restaurant website.
    Does this help with Firefox?

  • After downloading the latest upgrade of Adobe, I can no longer open files that are PDF's.  Why do I keep getting error 0.104?

    Since October 23rd, after downloading the recent upgrade for Adobe Reader,  I continually keep getting error code 0.104 whenever I try to open a file that is in PDF format.  No matter if I'm using Internet Explorer or Chrome.  Huge waste of time!  I have restored the Adobe to previous upgrade of September 2014, which was working fine.  I have restarted the computer several times since I restored to prior version with no luck at all.  

    This is the message i keep getting when I try and open my PDF files that are on my desktop. I run a Macbook Pro. I checked for updates on system and adobe all say unto date?
    Adobe Reader could not open 'Employment Application(1).pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).

  • Is there an automated way to scan my multimedia folder for files that are there and not in my library and add them ?

    Is there an automated way to scan my multimedia folder for files that are there and not in my i tune library and add them to y existing library ?
    I recenty had a damaged i tune library and had to import an old version.
    This last one does not have many of the CD I have copied the past months. And I don't know which ones these are either as they are too many of them.

    This will list files that are in the iTunes DB but the files are not in the media folder…
    http://dougscripts.com/itunes/scripts/ss.php?sp=listmias
    This will list files that are in the media library, but not in the iTunes DB.
    http://dougscripts.com/itunes/scripts/ss.php?sp=musicfolderfilesnotadded2
    I think it may misbehave with ringtones & some of the obscure media files, but they are both really powerful for repairing mangled libraries.
    I would create a new smart playlist for 'Tracks added since (todays date)' so you can easily find any tracks that you add back to iTunes.
    Doug has a lot of scripts for iTunes, spread the karma & donate if they are useful to you

  • Why doesn't my pdf files that are on my iPad show up on my iMac or mac book pro

    Why doesn't my pdf files that are on my ipad show up on my imac or macbook?

    Have you copied them from your iPad ? If you are using the 'sync collections' setting then that doesn't copy items between devices/computers, all it does is if you move a book/PDF into a collection on one device/computer then if that book/PDF is also on your other device(s)/computer(s) then it will be moved into the same collection on them.
    If you connect the iPad to the computer that you sync it to and do File > Devices > Transfer Purchases then it should copy them over to your Mac's iTunes (that should copy PDFs and epubs that are in the iBooks app, not just actual ibooks) - in the iBooks app on your Mac you might then need to do File > Move Books From iTunes to move them over to it.

  • How to read .dat files that are hidden?

    Is it possible to read .dat files that are set to hidden? 'cause what i did was i created a .dat file and set its attributes to hidden and my Read file code cannot read hidden files.
    here's my Read file code:
    Scanner read=new Scanner(FileReader("C:\password.dat"));
    and another thing, how do you Write a .dat file that is hidden too? 'cause my password.dat file needs to be updated.
    here's my Write file code:
    PrintWriter write=new PrintWriter("C:\password.dat");
    thank for the help.

    There should not be any problems opening up hidden files. Your problem is probably elsewhere (for example, you didn't escape the backslash, so what you posted is not your code).

Maybe you are looking for

  • REP-1057: ' PATH_TO_REPORT/report.rdf' is not a valid Report Builder file.

    Current Level : Report Builder 6.0.8.27.0 We migrated custom reports build on Report 2.5 to 6.0.8.27.0 on apps/db version from 11.0.3 / 8.0.5 to 11.5.10.2/9.2.0.6. Platform was moved from HPUX to Redhat Linux 4. When we open migrated reports then ori

  • Comp 3 new user needs help !! (please)

    Not sure which setting to use, have tried MPEG-2 5.0 2 pass and had no audio. Do I need to select audio seperately (eg AIFF 48-16). Anyway, now I can't seem to submit. I've daged and dropped the destination (desktop) and I've draged and droped the so

  • Planning ADM Driver 11.1.1.3?

    Is it inlcluded in the install? Is it needed in 11.1.1.3? I can't find a download for it on edelivery...... Thanks

  • Music Videos in iTunes have audio, but no picture

    Recently, I noticed that when I click on a song in iTunes, the audio for the song will play, but not the picture. I have found, however, that by going to View > Video Size, and then clicking on any of the sizes, the picture for the video will appear,

  • Issue with SOAP attachment boundary

    Hi All, We are building an application which retrieves documents from server and passed it to client side as Soap + MTOM attachments. We are using IBM webspere and webservices at the server end. And Java Webservices (JAX-WS) at the client end. We are