How to delete all file in a directory

Hi,
Myself is Lokesh....can anyone tell me how can we delete all existing mail file which i kept in linux (PATH IS: /usr/share/mailfile/)...the mail file extension is *.MAIL. Please help me in sortout this problem...

See listFiles (FileFilter) and delete ().

Similar Messages

  • Deleting all files in a directory

    Hi,
    Is it possible to use cffile to delete all files in a
    directory. I have a function that creates a file in seperate parts
    and places the finished file into a folder. But I need a check to
    delete all files currently existing in said folder. I understand it
    is possible to query a folder for existing files and then use that
    query with cffile to delete the files... I just don't know how to
    do it.
    Thanks for your help

    I am not postivie, but I think I recall learning that the
    delete all function is prohibited via CF. You can delete specific
    files, though.
    If this is, in fact, the case, you could query the directory,
    and then loop through the resultant query, deleting each file one
    at a time.

  • Anyone knows how to delete a file from a directory?????

    hi there
    anyone has any idea on how to delete a file from a directory? delete(String filename)? thank you.

    Hi,
    Check this link.
    Gives you an example code to show how to delete a file.
    http://examples.oreilly.com/jenut/Delete.java
    Hope this helps.
    Roopasri Vittal
    Developer Technical Support
    Sun Microsystems
    http://sun.com/developers/support

  • How to remove all files in a directory in java?

    I have tried method delete() of File ,
    but no effect!
    can anyone help me!
    thank you

    So, you have a directory and you want to delete all files in the directory. Here is some (untested) code:
    File dir = new File("C:\\tempdir");
    File[] files = dir.listFiles();
    for (int i = 0; i < files.length; ++i) {
      if (files.isFile()) {
    files[i].delete();
    Jesper

  • Time machine  how to delete all files?

    time machine:   how to empty and delete all files?

    Please check to let us know what version of AirPort Utility that you have so we can provide the correct instructions to erase the Time Capule disk.
    Open Macintosh HD > Applications > Utilities > AirPort Utility
    Click the AirPort Utility menu just to the right of the Apple icon in the upper left corner of the screen
    Choose About AirPort Utility
    What version of AirPort Utility do you have?

  • How to delete all files and folders (with files) in IsolatedStorage.

    Hi awesome programmer:-) The code I have to clean up the local folder doesn't work properly so I won't even bother posting it here. I basically want to have a "master reset" option to remove all new created files and folder in the local folder.
    Can you give me simple code to remove all files/folder so the app goes back to the state it was when the user installed it for the first time? Thanks in advance. ps I were able to delete a directory(-ies) with this method:
    private async void DeleteDirectory(string directoryName)
    try
    var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(directoryName);
    if (folder != null)
    await folder.DeleteAsync();
    this.Dispatcher.BeginInvoke(delegate()
    txtUpdateFeed.Text = "Folder < " + directoryName + " > deleted.";
    catch (Exception ex)
    this.Dispatcher.BeginInvoke(delegate()
    txtUpdateFeed.Text = "Delete Directory << " + directoryName + " >> Error: " + ex.GetBaseException().Message.ToString();
    It seems to work, I have not tested with all conditions though. Anyway let me put up the code so you can see I have been trying: This is to delete everything but not all files are deleted:
    private void WipeAllData(bool bln)
    try
    txtUpdateFeed.Text = "Removing files...";
    if (bln)
    txtUpdateFeed.Text = "Removing folders...";
    //Delete videos directory
    DeleteDirectory("videos");
    //Delete pictures directory
    DeleteDirectory("pictures");
    txtUpdateFeed.Text = "Folders removed.";
    //Delete the rest of the files
    var iso = IsolatedStorageFile.GetUserStoreForApplication();
    foreach (string name in iso.GetFileNames())
    iso.DeleteFile(name);
    BtnWipeAllData.Content = "Wipe All Data";
    VideoCameraPowerValue = "on";
    BtnVideoCameraPower.Content = "Video Camera: ON";
    PhotoCameraPowerValue = "on";
    BtnPhotoCameraPower.Content = "Photo Camera: ON";
    txtUpdateFeed.Text = "Files removed successfully.";
    catch (Exception ex)
    MessageBox.Show("Wipe All Data Error:\n" + ex.Message.ToString());
    Why isn't all files being deleted?

    Hi Clint William Theron,
    Based on your descriptions, I know that when you run the above code, it does not delete all the files, then have you checked that which kinds of files or in which folder the files can not been deleted?
    Besides, if you want to let the app go back to the state it was when the user installed it for the first time, then an easy way is to uninstall and reinstall it.
    Best Regards,
    Amy Peng
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Delete all files in a directory not working for some files

    I have a requirement like wants to delete all the files in a directory. (These files got generated through some other program.)
    Problem is file.delete() is returning false for some of the files..
    (donno the reason .. could be bcoz of file closing issues/locking issues.)
    Looking for a solution where i can delete a file forcefully irrespective of whether the file is opened or not.
    Thanks
    Srini

    are you on windows? if so, it's almost impossible to delete something another process has open.

  • How to delete all files on hard drive

    I am selling my iMac 27" and I want to deleted all of my files except for the IOS Lion.  Can anyone explain how to do this and get the hard drive back to a factory setting so that I can sell the computer and not have to worry about content being on the hard drive.  I have a external hard drive backup.
    Thank you,
    Scott

    Hi Scott,
    2 ways to go...
      1. Insert the Mac OS X Install disc that came with your computer, then restart the computer while holding the C key.
       2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
          *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
       3. Click the Erase tab.
       4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
       5. Select your Mac OS X volume.
       6. Highlight the drive, select Partition Tab, then Format type... MacOS Extended Journalled, select the Security Options button, choose Zero Out Data, Erase... after completion do a new install.
    Or...
    Open System Preferences>Accounts, unlock the lock, click on the little plus icon, make a new admin account, log out & into the new account.
    In the same pref pane highlight your old account, click the little minus icon, then use Disk Utility to Secure Erase Free Space.

  • How to delete all files on old mac?

    Just got a new Mac Dual Core Intel Xeon for my main work computer. Transferred files from old G5 Tower to this new computer. NOW, I need to erase all files on the old G5 so new user can start from scratch (reinstall software, delete all of my old files, etc.)
    What is the best way to do this so that all is erased properly and no settings carry over from my user account?
    THANKS in advance!

    This is how you can erase the HD inside your iMac
    -Insert the installation disc 1 and sthut down your Mac
    -Start your Mac again while holding down the C key
    -Now your Mac should boot from the CD, this can take some time.
    -After a while you will see a installation screen where you can chose a language.
    -Chose English and continue.
    -Then click some time's next and agree with the "Software Agreement".
    -Open Disk Utility. Top menu bar --> Utilities --> Open Disk Utility.
    -Select your hard disk in the list of disks and volumes on the left side
    -Go to the erase tab on the right side
    -Select "Mac OS Extended (Journaled)"
    -Type "Macintosh HD"
    -Click to the options button
    -Select the option "Zero Out Data"
    -Press OK
    -Press the erase button
    -Wait until Disk Utility is ready and close it
    Now you can extit the installer or continue to install a clean OSX.
    Hopefully this is helpfull or solved your problem. Consider rewarding some points!
    Please see the "helpfull" and "solved" button's on top off this message! Apple: Why reward points?

  • How to get all files in one directory

    Hi there,
    is there any way to get all the files in one directory?
    e.g. a method
    File[] getAllFiles(String directory){
    Thank you

    Just out of interest, which part of the File API was confusing?
    http://java.sun.com/j2se/1.5.0/docs/api/index.html
    If you look down the left-hand side, you'll see a frame listing "All File". If you select "File" from that list, it opens up the API in the right-hand frame. Quite near the top you'll find "listFiles".
    I only ask as this (and other questions easily answered by looking at the API) are frequently asked. Did you overlook it when you read the API or did you just not read it?
    I really want to know. I think there is scope to cater for that behaviour within this site. A nice API finder would be good; something more intelligent than the search function (which people use less frequently even than the API docs).

  • How to delete all "files that cannot be found" files faster! Desperate!!

    Hey!! So for the past year and a half, i have had hundreds and hundreds of songs that read "----- file cannot be found--" due to me listening to cd's through itunes, without properly importing them. The result was every song file was saved without the song! So now after i imported the CD's correctly, i have quite a few duplicates of hundreds of songs, and the only way i find out which song is the duplicate is by manually trying to play the individual song. I wish to DELETE all the BLANK songs whether they be duplicates or just single files. I was just tolerating it all this time, but now that i ordered my itouch, i need to consolidate my library! Please help, thanks!!
    PS: I saw other threads where people wanted to delete duplicate songs, but i didn't know if the programs that where reccomended to them deleted a random duplicate, because if that is the case, it could delete the good copy of the song, where i would want it to delete the blank copy. Thanks again.
    = ]
    THANKS AGAIN!!! PLEASE HELP THIS PROBLEM IS KILLING ME! =O
    Message was edited by: mr.nooby

    Here is a script to find dead tracks.
    Rename it to FindDeadTracks.js
    Run iTunes.
    While iTunes is running, double click FindDeadTracks.js to run the script.
    http://ottodestruct.com/itunes/FindDeadTracks.txt
    You can look at the resulting Notepad document it creates, if you like, to make sure it found files you were expecting.
    Then to get rid of those tracks, download this: http://ottodestruct.com/iTunes/RemoveDeadTracks.txt
    Rename it to RemoveDeadTracks.js.
    Run iTunes.
    While iTunes is running, double click RemoveDeadTracks.js to run the script. It'll remove all the exclamation marked tracks.
    For the duplicate tracks, you pretty much need to look at those on a case-by-case basis.

  • How to delete all files

    I want to delete all pdf files on my phone to release room,but deleting them one by one seems the only way to me.so please help
    my operating system is WP 8,and the version of
    adobe reader is 10.1 build 76837.

    [topic moved to Windows Phone subforum]

  • Can i delete ALL files in directory ?

    i create a upload test using FileReference & PHP.
    In this scenario user upload files to http server.
    Now how can i delete all files in /files/uploads folder in AS3
    AS3 Code:
    req = new URLRequest();
    req.url = ( stage.loaderInfo.parameters.f )? stage.loaderInfo.parameters.f : "http://www.website.com/test/upload.php";
    uploadFile = new FileReference();
    select_btn.addEventListener( MouseEvent.CLICK, browse );
    uploadFile.addEventListener( Event.COMPLETE, complete_func );
    uploadFile.addEventListener( DataEvent.UPLOAD_COMPLETE_DATA, show_message );
    function browse( e:MouseEvent )
              filefilters = [new FileFilter('Images',"*.jpg;*.png;*.gif")];
              uploadFile.browse( filefilters );
    function complete_func( e:Event )
              trace( 'complete !' );
    function show_message(e:DataEvent)
    if (e.data == 'ok')
              label_txt.text = 'The file has been uploaded.';
    else if ( e.data == 'error')
              label_txt.text = 'The file could not be uploaded.';
    PHP Code:
    <?php
    $uploads_dir = './files/uploads';
    if( $_FILES['Filedata']['error'] == 0 ){
              if( move_uploaded_file( $_FILES['Filedata']['tmp_name'], $uploads_dir.$_FILES['Filedata']['name'] ) ){
                        echo 'ok';
                        exit();
    echo 'error';
    exit();
    ?>

    You need call another PHP file
    <?php
       $directory = './files/uploads';
       getDirectoryList ($directory);  
       //This function find all the files in the directory
       function getDirectoryList ($directory)
         // create an array to hold directory list
         $results = array();
         // create a handler for the directory
         $handler = opendir($directory);
         // open directory and walk through the filenames
         while ($file = readdir($handler)) {
           // if file isn't this directory or its parent, add it to the results
           if ($file != "." && $file != "..") {
        //$results[] = $file;
         // Delete Files
        $filename = $file;
      unlink($filename); //this delete a file
         // tidy up: close the handler
         closedir($handler);
    ?>

  • I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I

    I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I try to launch it, I get a screen headed Photoshop CS5 Extended Trial.  It asks for the serial number and says that my trial has expired.  It rejects the serial number from the Adobe case saying "This Serial Number is not valid for this product".  It thinks that I still have the expired Trial Version installed.  How do I convince it (the program) that the Trial Version is long gone and the currently installed product was installed with a valid and accepted serial number????

    Let me know how it goes. Go into your Adobe account and register your serial number asap.
    https://www.adobe.com/account/my-products-services.html
    That way, should you lose it or you need support, it is on record that it's yours and you can fetch your s/n it from anywhere.
    There are too may sad stories here, where people forgot and the box is buried or lost.
    Gene

  • Time capsule intern.1TB hard drive.How can I delete all files

    Hello How can I delete all files from my timecapsule.
    I have connectet it with Wifi or ethernet. It is not possible.
    I have made a reset.
    I have tried it often.
    Please help
    Greetings from Vienna
    Pepimeier

    If you open Macintosh HD > Applications > Utiltiies > AirPort Utility and click Manual Setup, are you able to access the settings for the Time Capsule?
    Or, does AirPort Utility scan for the Time Capsule and then not find it?

Maybe you are looking for

  • Unable to login in sap development system

    When iam applying service packs, some has restarted the server. After restart the system everything is fine MMC is started. Database connection is ok. tp connection ok. Every thing is ok.  When iam trying to login sap system I entered ddic user 000 c

  • How do I get my ical on the icloud?

    I have my ical on my imacs and I then sync them to my iphone.  How do I sync these to the icloud?  I am using OSX 10.5.8 and 10.6.8 on my imacs.  Once I have my ical info on my iphone is there away to get this info backed up to the cloud?  I have tri

  • IMovie full quality export problem...

    Hello, I filmed a widescreen video with a mini dv cam, which runs flawlessly smooth and clear as a bell at full screen in iMovie... but when I export it in either a full quality .dv, or the highest quality .mov and play them at nearly full screen in

  • How to rename podcasts in store?

    So 3rd time was a charm and iTune Store accepted my podcast, however when resubmitting my RSS feed I had to rename it. I was told at the time I could rename it after it was accepted. I am not sure where to do this. I prepared the RSS Feed in the Mac

  • Cannot create 8iEE db

    I have installed 8iEE on RedHat 6.1 according to "User Friendly Install of Oracle8i on Redhat linux 6.1" (exiting without creating a database). However, when I try to make a database using dbassist I get a "not logged on" error when dbassist starts t