Not more than 4 files in a directory .... ?????

Hi
Do you know how can restrict a directory only to allow 4 files ....
I have a program in C who save image every second, and if i leave it running mayby i have to said good bye HD space, :)
Thge point is that i want to use the output, but i only want 4 files .... not a sequence .... i mean
cam1.bmp , cam2.bmp, .... cam9.bmp ..... cam23.bmp ...
i neen cam1.bmp, cam2.bmp, cam3.bmp, cam4.bmp ....and cam5 is now CAM1.bmp and cam6 is cam2.bmp ...i mean delete the old one and use the new image but with the same name ......
please ...help me .... i only need to know how or what can i use to start developing ....
Thank you !!!
:)

This fixes a couple of the problems with the previous ones renameTo needs a file and I forgot some semi colons.
import java.io.*;
import java.util.*;
public class CleanUp
     public static void main(String args[])
          throws IOException
          // Check arguments 
          if(args.length==0)   
               System.out.println("Usage: java <directory with the images>"); 
          // Delete other files 
          FileFilter filter=new FileFilter() 
               public boolean accept(File path)   
                    return (!path.getName().endsWith(".bmp"));   
          File dir=new File(args[0]); 
          File[] files=dir.listFiles(filter); 
          for(int i=0; i<files.length; i++)   
          files.delete();
          // Get list of files
          filter=new FileFilter()
               public boolean accept(File path)
                    return (path.getName().endsWith(".bmp"));
          files=dir.listFiles(filter);
          Arrays.sort(files);
          // Check length
          if(files.length<4)
               return;
          // Delete the older files
          for(int i=0; i<files.length-4; i++)
               files[i].delete();
          // Rename newest files
          for(int i=files.length-4; i<files.length; i++)
               files[i].renameTo(new File("cam"+i+".bmp"));

Similar Messages

  • Finder not displaying all files in remote directory

    Sorry, this is a repost as I have gotten no response from my original request here: Finder not displaying all files in remote directory
    I've exported pictures from iPhoto on my iMac to a shared directory on my mac mini. When I access that directory from my iMac, I can see some but not all of the pictures. I know the pictures exported properly because I can see them all from the mac mini. I can open up a terminal window on my iMac and see all of the files; I can also open those files from the terminal.
    I'm running OSX 10.9.4 on both computers, with the mac mini also running OSX Server. I've placed a screen grab below from my iMac of what Finder sees vs what I can see from the terminal.
    Why isn't Finder displaying all of my files?

    thanks for responding
    Adding a new file to the shared folder results in me being able to see the new file from my clients regardless of where it was added from, however the "hidden" files do not suddenly pop up.
    I tried a few more experiments that had interesting results, but still didn't lead me to an answer.
    First I tried copying the files from the remote directory to a local directory; I did this in 2 different ways and had different results. Method A) I copied files from the mounted share to a local dir: "cp /Volumes/MyShare/dir/*.JPG .". Method B) I copied the files using secure copy: "scp user@server:/path/to/dir/*.JPG .".
    Method A resulted in Finder not being able to see the files in the local directory, while Method B did. This was interesting and lead me to suspect an issue with the way I am sharing the directory on the server. From Server settings I have both afp and smb checked. I tried enabling only one or the other and reconnecting; but this did not fix the problem.
    Next I tried exporting the photos from iPhoto again. Exporting them locally results in files that Finder can see. Exporting them to my server results the same bad behavior
    Getting desperate, I also tried renaming all of the files from "*.JPG" to "*.jpg" but this didn't help.
    One last experiment, I see the same behavior from both another Mac and a PC on my local network... FTP works fine.
    Any more ideas?

  • HT1414 C apple i need to know few things,first of all i shall tell my scenario. I got an iphone 3gs from my uncle in US. I m at india k. well , in that iphone it showing activation screen and trying to activate. not more than that..plz help!

    C Apple, i need to know few things,first of all i shall tell my scenario. I got an iphone 3gs from my uncle in US..after long waiting. I m from south india, living at God's country called Kerala k. well , in that iphone it showing activation screen and trying to activate. not more than that..plz help!
    means.. in simple words, it is trying to activate and all( searching wifi,, taking few minutes..again searching...if it couldnt find any wifi - telling .. try connect using itunes an all)...well any way. finally I try connect to a wifi network, with full speed...3mbps..from Ravi's internet cafe in downtown.
    All after Im getting the below message from that white candy box!( thats all I can use now, because, in my dreams iPhone is something great,  that mankind ever seen....but this really disappointed me......im simpling blinking!!(same with itunes too)
    ""Your iphone could not be activated because the activation server is temporarily unavailable. try connecting your iphone to itunes to activate it, or try again in a couple of minutes.
    If this problem persists, contact apple support at apple.com/support""
    EVERYDAY .EVERTIME.. I C this message and sleep....no use.....and i use to charge that 'white candy box' to c this message!
    I try searching internet and all for solutn...but no one knw about it..but there are...some one me abt method called jailbreaking ..rednw..white snw ..ultrasnw and all...I dnt knw why it is so complicated to troublesht...apple is suppose to be simple and friendly.
    C why u manufacturing these stuffz like this, if does'nt serve the any of its purpose ....or useable to any of its features atleast....C i wont be that disapppointed, if u put an option to playbck music or video during activation and all...
    If you are responsible for manfacturing such unuseable thing, then its ur responsible to destroy it too.....
    anyway now everyone knws that ..I have an apple iphone with me, but that doest make me proud at all...
    Finally I have only few questions to ask...
    1 will it work with my vodafone sim in kerala?
    2 is any way , i can hear any music out frm it?
    3 will i become a proud iPhone user?
    I am already fedup with asking questions..begging for an solution.....
    I hope so you can help to figure it out, without any complications....thank u!

    It was not legitimately unlocked by the carrier it was originally locked to. ONLY the carrier it is locked to can authorize unlocking it.
    In order to allow it to be used on a different carrier, the phone was hacked or jailbroken. An unauthorized modification was made to the phone. That modification has damaged the phone. You can not get support for it here or from Apple.

  • How to restrict the delivery quantity not more than target quantity?

    Dear Gurus,
    How to restrict the delivery quantity not more than target quantity in a scheduling agreement? I think there are 2 methods.
    1. I found that setting 0 in Overdelivery Tolerance Limit in Info Record is not effective. Why?
    2. I want to set E for the message but can't find the place. The message is generated when entering and saving quantity as delivery quantity that is larger than target quantity. How can I set E to a message (067, as I remember)
    Any other effective method? Please advice. Thanks.
    Regards,
    David

    Dear all,
    It is not OK after checking everywhere you mentioned. I tested in 2 clients. In the development enviroment client, it works whatever E or W. In test enviroment, it does not work (meassge is W).
    I think there must be somewhere besides of those you menetioned.
    I notes that SAP help for the overdelivery tollerance setting of scheduling agreement: 
    Overdelivery Tolerance Limit
    Percentage (based on the order quantity) up to which an overdelivery of this item will be accepted.
    Dependencies
    If you have set the indicator in the Partial delivery/Item field to 'D' (partial delivery allowed), this takes priority. It makes no sense to define a tolerance limit for overdelivery in such case.
    Where can I see: 'the indicator in the Partial delivery/Item field to 'D' (partial delivery allowed)'? I want to check it.
    Pls help! Thanks.
    Regards,
    David

  • Query Builder accepts not more than 60 fields in a single dataset

    Query Builder accepts not more than 60 fields in a single dataset. Once we try to enter 61st field - it pops up with a message. Is there some setting that we need to change.
    Please help me.
    Thanx & Regards,
    Rajeev Goel

    Query Builder accepts not more than 60 fields in a single dataset. Once we try to enter 61st field - it pops up with a message. Is there some setting that we need to change.
    Please help me.
    Thanx & Regards,
    Rajeev Goel

  • Change Account Duration for ISE Guest User can not more than 5 days

    Extending guest account duration can not more than 5 days.
    On portal we can change it to more than 5 days, but the account always expired after next 5 days.
    Email notfication sent after change duration also said the account only have 5 days of duration.
    I'm using ISE 1.2 patch 2.

    Step 1 From the Cisco ISE Administrator interface, choose Administration > Guest Management > Settings > General > Purge.
    The Purge Settings page is displayed.
    Step 2 To schedule a purge operation, check the Enable purge settings for expired guest accounts check box.
    Step 3 Configure the following available options:
    a. Enter the purge interval, in number of days. Valid range is 1-365.
    b. Specify the hour of the day when the purge should occur.
    Date of last purge displays the date and time when the last purge operation occurred.
    Date of next purge displays the date and time when the next purge operation is scheduled to occur.
    Step 4 To immediately execute a purge of expired guest user records, click Purge Now.
    This executes a purge manually even if Enable purge check box is not checked. This option provides you the freedom to purge records whenever you seem fit.
    Step 5 Click Save
    Please check the point 3 find the value is so that it may engaged.

  • I have my catalog "Back Up Each Time Lightroom Exits" checked, and always have. That means the catalog should have been backed-up and saved everyday, if not more than once on some dates. So with a a major problem now and needing to use the Catalog backup

    I have my catalog "Back Up Each Time Lightroom Exits" checked, and always have. That means the catalog should have been backed-up and saved everyday, if not more than once on some dates. So with a a major problem now and needing to use the Catalog backup from last Friday, I go to my Lightroom Backups folder - and the most recent one showing not only isn't yesterday, it's OCTOBER 28 !?? Where the hell are the daily backups between October 28 and November 14?

    Oh wow - JET LAG strikes agin - my apologies; I have located the missing weeks of back-ups. After getting home from a 30-day trip to Europe, I had changed the location of my LR catalog back-ups to an external drive, and forgot that I did that. I have found them, and all is good. Never operate Heavy Machinery without enough rest. Cheers

  • Per Payment Document Expenses added not more than 5 lines

    Hai Experts,
    In outgoing payment Expenses added per document not more than 5 lines per document. Kindly provide SP_TN for this case..
    Regards
    Mohamed Yousuf Ali M I

    Hi
    Try This
    if @object_type = '46' and @transaction_type in ('A','U')  
       begin
            if  exists(Select distinct 'Error'
            from   VPM4 T0 INNER JOIN OVPM T1 ON T0.DocNum = T1.DocEntry where T0.LineId > '5' and T1.DocEntry = @list_of_cols_val_tab_del)
              begin
       SET @error = 1234
       SET @error_message = 'Outgoing Payment lines Not More than 5 lines'
           end
    end
    With Regards
    Balaji Sampath

  • How to restrict not more than 9 hrs in Timesheet

    Hi
    Is there any way to restrict not more than 9 hrs in Timesheet in PWA 2010
    Regards
    Santhu

    Hi Santhu,
    In server settings, timesheet settings, set the maximum hours per timesheet:
    Hope this helps.
    Guillaume Rouyre - MBA, MCP, MCTS

  • It has been not more than 10 days since i bought iphone 5s 32gb and the finger print scanner is not detecting the prints.what to do??is it an issue with the device or iOS??

    It has been not more than 10 days since i bought iphone 5s 32gb and the finger print scanner is not detecting the prints.what to do??is it an issue with the device or iOS??

    Standard practices:
    Restart the device (power off completely, then back on) - retest.
    Reset (hold sleep wake and home buttons until apple logo appears) - you can try this, but it is most useful when your device is frozen.
    Restore to factory settings - retest.
    Make an appointment at an Apple retail store genius bar if the above did not resolve the issue.
    HTH.

  • I had an iPod Classic 5th Gen that I upgraded from 30gb to 80gb.  The problem I'm having is that it will not more than about 5.4gb worth of songs.  The iPod begins to freeze mid sync and the (-69) error message haults the sync.

    I had an iPod Classic 5th Gen that I upgraded from 30gb to 80gb.  The problem I'm having is that it will not sync more than about 5.4gb worth of songs.  The iPod begins to freeze mid sync and the (-69) error message haults the sync process.  The hard drive has been upgraded, it has a new logicboard (with 128mb RAM), new housing, battery, hold / headphone jack.  Basically the only original parts are the bezel, click wheel, screen, and data ribbons. Have attempted the 3Rs and have also tried to isolate potentially corrupt audio files and remove them, but this did not seem to be the primary cause.  The sync failure consistently happens at just under a 1000 songs (5.4gb) and then it starts to error (-69) any song after that.  Your advise would be enthusiastically received.

    Here is what worked for me:
      My usb hub, being usb2, was too fast. I moved the wire to a usb port directory on my pc. That is a usb1 port which is slow enough to run your snyc.

  • How to read icons from more than a single virtual directory.

    Is it possible to define, for my application, more than one directory for searching images and icons ?
    How to ?
    Tks
    Tullio

    Do You mean FORMS_PATH is searched for icons and images ?
    Does it conflicts with default.icons.iconpath in Registry.dat file ?
    Tks
    Tullio

  • Not more than one service order against same sales document item

    A service order gets created against the sales order item as per
    standard SAP process. As credit management is active, when the order
    is under credit block  for the customer the service order gets created only after the
    credit block is released.
    On revising the order line value the sales document goes for a block
    again. Service order is locked. Both seem to be logical.
    But on releasing the credit block  this time ,  it creates one more service order against the same sales order item. Would logically expect the service order is
    unlocked on release from credit block.
    Can u pls explain this behavior ??  How do u avoid a new order creation and unlocking of the service order when the credit block is released.
    Would like to avoid any change in the service order status once it has been created irrespective of subsequent credit status of the sales order.
    regards
    Ramanujam

    Hi  lisa ,
    It is not possible to enter more than one service performer for a service in sales order .
    But you can  perform the service with two people and have two service confirmations.
    The time entered in service confirmation will be reflected in invoice only(if time and material).
    Also you cannot enter the time sheet with respect to sales order , it is only valid for project task and
    and time types.
    Regards,
    Harish

  • F110 payment for invoice not more than USD 25000

    Is there a way to set up the system for F110 so that the payment per vendor cannot be more than USD 25000. Any amount above it has to be paid via approval.

    Hi both,
    There is some standard configuration indeed. In trans. FBZP, choose "Payment methods in company code" and you will see a field "Maximum amount" (T042E-BISBT). If you set it to 25000 USD in all relevant payment methods then the payment program (trans. F110) will put the vendor payment to exceptions (with error FZ618 - Payment amount is not within the limits allowed) if the payment amount exceeds this limit. I have just tested in sandbox and it works like this:
    - it does not look at single item amounts, but at the total to be paid together in one REGUH line (e.g. if you have one invoice for 11000 USD and one for 15000 USD, then both will be blocked if they fall in the same payment proposal)
    - early payment discounts are deducted (e.g., if you have an invoice for 25500 USD with a 3 % discount (24735 USD net) and nothing else then it will be paid)
    - however, if the payments are split (e.g., after ticking "Individual payment" LFB1-XPORE in vendor master), then it considers each invoice separately, even if their total exceeds the limit
    - SAP help says that if you enter the payment method directly into the item (rather than choosing it from vendor master), then the limit is not taken into account.
    So, from the above you can see that it is not a complete protection (there are loopholes and back doors) but it is the most simple - and standard - thing you can do.
    Would this help? If not, then a user exit would be a solution.

  • Multicolumn Listbox not more than 32 Symbols?

    I have a Multicolumn Listbox. In the first row, I have a symbol (the diamond). Configuration of the Listbox is done via the frontpanel editor. Data is inserted programmatically, as well as the size, visibility and colors of the symbols are set programmatically. Basically, everything works fine. BUT when I insert more than 32 rows into the Listbox, there are no symbols on rows 32+.
    I did not find any signs that the number of rows or number of symbols is set to 32 anywhere in the code or on the frontpanel editor.
    What could be the reason for this strange behavior?

    mibeer wrote:
    So the strang behaviour could probably be reproduced by just adding programmatically a random number of entries to a multicolumn listbox upon click of a button.
    Well, guessing does not really belong here.
    If you suspect a LabVIEW bug, wire up a small example that demonstrates the problem and we can immediately eliminate the "probably" and get a definite answer instead. We like facts better!
    Please do so! Thanks.
    LabVIEW Champion . Do more with less code and in less time .

  • Java process takes not more than 700 MB

    Hi,
    we start java with -Xms128M -Xmx1280M -Xrs but after reaching 700 MB the process crashes:
    java.lang.OutOfMemoryError: unable to create new native thread
         at java.lang.Thread.start(Native Method)
    The server has 500 MB free memory when the process crashes.
    Whats the reason for this crash and how can I use java with more than 700 MB?
    We use J2RE 1.4.1_02-b06.
    Regards,
    Dirk

    from http://www.insanelymac.com/forum/index.php?showtopic=54778
    try is deleting your bluetooth preference files - there could be a problem with the new 'blued' daemon using your old 10.4 preferences if you just upgraded (or archived and installed) to 10.5.
    I'd suggest trashing:
    /Library/Preferences/com.apple.bluetooth.plist
    ...and then looking in:
    ~/Library/Preferences/
    for anything 'com.apple.bluetooth'. ('~' means your home folder).
    After you do that, try a restart and see what happens.

Maybe you are looking for