Polling a particular directory, retrieving only new files

Hi,
I have a requirement of polling a particular directory, and retrieving all new files posted. Say, i have a file called file1 in a particular directory, i keep polling the same directory every "n" minutes or even seconds, and will try to fetch file1 only when there is a semaphore file called file1.ready exists for file1.
This is in Solaris.
How can this be implemented?. Any help will be greatly appreciated.
Thanks

Take a look at java.io.File which represents an abstract path such as a directory or file. You'll probably be particularly interested in File.exists().

Similar Messages

  • Polling a particular directory, retrieve only new file(s)?

    Hi,
    I have a requirement of polling a particular directory, and retrieving all new files posted. Say, i have a file called file1 in a particular directory, i keep polling the same directory every "n" minutes or even seconds, and will try to fetch file1 only when there is a semaphore file called file1.ready exists for file1.
    This is in Solaris.
    How can this be implemented?. Any help will be greatly appreciated.
    Thanks

    you can use the file modified dates to figure out whats new and whats old.
    May be you can compare them against the last time that you ran the process.

  • How to make BPEL File Adapter read only new files?

    Hello
    we have BPEL processes that define to run from bpel component - file adatper-
    when a file come into location that it is path on the linux server . the bpel start run when "File Adapter" bpel component recognize that new file come to the location. its PollingFrequency define to 5. property name="DeleteFile" value="false" so the files remaine there.
    we want to migrate the bpel to new SOA version so we did export and deploy to new SOA Domain.
    the location of the file adapter is the same.
    but when the BPEL processes deployed its start to run for all the files that are in this location- that the file adapter define on .
    even the original soa tooks those files and start the BPEL processes for each one of them. also the new SOA that we did deploy to the BPEL processes take those files even if they are very old.
    we want the file adatper we take only new files . the start point is the time when we do deploy to the process so if we do deploy in 10:00 am we dont want this bpel will take files from 9:00 or earlier time
    Please help , how we can do this?
    Thanks

    thank you
    do you kno hat the value means in the example:
    Java mon amour: File Adapter metadata with SOA Suite
    <property name="jca.file.LastModifiedTime" value="1293041258635">
    what should I rite for read only the files that are only neer then yesterday?

  • Download only new files?

    Hi,
    Is there an easy way to download only new files from the
    server without having to go through and select the various folders?
    My programmer changes a handful of files now and then, but I end up
    selecting every folder that he might have touched every time...I'm
    sure there is a more efficient way to do it? If so, is there a way
    to exclude log files? They are huge, take forever to download and I
    don't need them.
    thanks

    Synchronize will do that.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "GPaul" <[email protected]> wrote in message
    news:gp4alv$5ja$[email protected]..
    > Click on the Modified column in the files panel in
    Remote View, this will
    > list the files in the order of when they were modified.
    >
    >
    > "Lvanhoff" <[email protected]> wrote in
    message
    > news:gp49te$4ku$[email protected]..
    >> Hi,
    >> Is there an easy way to download only new files from
    the server without
    >> having
    >> to go through and select the various folders? My
    programmer changes a
    >> handful
    >> of files now and then, but I end up selecting every
    folder that he might
    >> have
    >> touched every time...I'm sure there is a more
    efficient way to do it? If
    >> so,
    >> is there a way to exclude log files? They are huge,
    take forever to
    >> download
    >> and I don't need them.
    >>
    >> thanks
    >>
    >>
    >
    >

  • How to get folder(directory path only not file path) from local file system

    Hi Firends,
    How to get folder(directory path only not file path) from local file system , whenevr i will click on browse button.
    Please give reply for this one , if anybody knows.
    Thanks,
    Anderson.

    Hi Anderson,
    if you're using flash.filesystem.FileReference - then it is run in black box - except of filename, size and creation data (and few other properties available after some operation succeeded). This is part of security features in Flash runtime (described in header section):
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference .html
    This for example implies that user can download a content to local machine - but that content cannot be loaded back into Flash runtime. For this you would need either Air runtime flash.filesystem.File:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.h tml
    (so you would created Air runtime based application: desktop or mobile but not web, even as standalone project) or you would need one of 3rd party tools that add file access/file information features to standard Flash runtime applications converted to standalone native applications.
    hth,
    kind regards,
    Peter

  • On-demand scanning for only new files or scan a list from a file

    I run a free to use file hosting service and with it are the risks of abuse for malware. In the past I've used ClamAV with a bash script to search for any files that are as old or newer than X minutes, usually about 5 minutes and put the found files listed line by line in a file and ClamAV will scan those files only. Put on a Cron for every 5 minutes to run. ClamAV's detection is pathetic though and has not caught most of the stuff it has needed to find. So switching over to Sophos Linux, it has done a great job already detecting multiple files of the uploaded files folder that ClamAV had already missed in the past. It takes just 3 1/2 minutes for it to scan through 3500+ files and archives totaling 17 gigs. I have it set to scan the whole directory every 5 minutes. This takes a while, even if it is under 3 1/2 mins. Ideally I want Sophos to only scan new files so it can be set to run every minute, or every 5 minutes, whether that be from it's command line or via it reading a file list. This way newly uploaded malware is taken care of as fast as possible for the security of the end users.  Here is the script file I use for Sophos already: #! /bin/bash
    PATH=/home/user:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    if [[ $UID -ne 0 ]]; then sudo "$0"; exit 0; fi
    # Directories to scan
    scan_dir="/home/user/directory/files/"
    # Virus relocation folder
    virus_vault="/home/user/directory/viruses/files/"
    # Create new log folder if it doesn't exist
    mkdir -p /home/user/directory/viruses/logs/$(date +%Y-%m)
    # Location of log file
    tmp_log_file="/home/user/directory/viruses/logs/$(date +%Y-%m)/sophos-scan-$(date +%Y-%m-%d)-tmp.log"
    log_file="/home/user/directory/viruses/logs/$(date +%Y-%m)/sophos-scan-$(date +%Y-%m-%d).log"
    # Scan files and remove (--remove) infected
    savscan $scan_dir -nc -ss -archive -all -suspicious -pua --quarantine -move=$virus_vault -p=$tmp_log_file
    # Format log
    echo " " >> "$log_file"
    echo " " >> "$log_file"
    echo "-----------------" >> "$log_file"
    echo " " >> "$log_file"
    date >> "$log_file"
    echo " " >> "$log_file"
    echo "-----------------" >> "$log_file"
    echo " " >> "$log_file"
    # move consolidate log to daily file
    cat $tmp_log_file >> $log_file
    # remove temporary file
    rm -f $tmp_log_file
    # make sure virus files are right owners
    chown -R user:user $virus_vault Here is what it's based off, what I did for ClamAV to find new files and scan those only. #! /bin/bash
    if [[ $UID -ne 0 ]]; then sudo "$0"; exit 0; fi
    # Directories to scan
    scan_dir="/home/user/example.com/files"
    # Virus relocation folder
    virus_vault="/home/user/example.com/viruses/files"
    # Temporary file
    list_file=$(mktemp -t clamscan.XXXXXX) || exit 1
    # Create new log folder if it doesn't exist
    mkdir -p /home/user/example.com/viruses/logs/$(date +%Y-%m)
    # Location of log file
    log_file="/home/user/example.com/viruses/logs/$(date +%Y-%m)/clamscan-$(date +%Y-%m-%d).log"
    # Make list of new files
    if [ -f "$log_file" ]
    then
    # use newer files then logfile
    find "$scan_dir" -type f -cnewer "$log_file" -fprint "$list_file"
    else
    # scan last 5 minutes
    find "$scan_dir" -type f -cmin -5 -fprint "$list_file"
    fi
    if [ -s "$list_file" ]
    then
    # Scan files and remove (--remove) infected
    clamscan -f "$list_file" --move=/"$virus_vault" >> "$log_file"
    rm -f "$list_file"
    else
    # remove the empty file, contains no info
    rm -f "$list_file"
    fi
    exit 

    Quick comment...
    Sophos has 'decision caching' to speed up files that haven't changed since the last scan, while also allowing files to be re-checked against the latest threat definitions.

  • On-demand scanning for only news files or scan a list from a file

    I run a free to use file hosting service and with it are the risks of abuse for malware. In the past I've used ClamAV with a bash script to search for any files that are as old or newer than X minutes, usually about 5 minutes and put the found files listed line by line in a file and ClamAV will scan those files only. Put on a Cron for every 5 minutes to run. ClamAV's detection is pathetic though and has not caught most of the stuff it has needed to find. So switching over to Sophos Linux, it has done a great job already detecting multiple files of the uploaded files folder that ClamAV had already missed in the past. It takes just 3 1/2 minutes for it to scan through 3500+ files and archives totaling 17 gigs. I have it set to scan the whole directory every 5 minutes. This takes a while, even if it is under 3 1/2 mins. Ideally I want Sophos to only scan new files so it can be set to run every minute, or every 5 minutes, whether that be from it's command line or via it reading a file list. This way newly uploaded malware is taken care of as fast as possible for the security of the end users.  Here is the script file I use for Sophos already: #! /bin/bash
    PATH=/home/user:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    if [[ $UID -ne 0 ]]; then sudo "$0"; exit 0; fi
    # Directories to scan
    scan_dir="/home/user/directory/files/"
    # Virus relocation folder
    virus_vault="/home/user/directory/viruses/files/"
    # Create new log folder if it doesn't exist
    mkdir -p /home/user/directory/viruses/logs/$(date +%Y-%m)
    # Location of log file
    tmp_log_file="/home/user/directory/viruses/logs/$(date +%Y-%m)/sophos-scan-$(date +%Y-%m-%d)-tmp.log"
    log_file="/home/user/directory/viruses/logs/$(date +%Y-%m)/sophos-scan-$(date +%Y-%m-%d).log"
    # Scan files and remove (--remove) infected
    savscan $scan_dir -nc -ss -archive -all -suspicious -pua --quarantine -move=$virus_vault -p=$tmp_log_file
    # Format log
    echo " " >> "$log_file"
    echo " " >> "$log_file"
    echo "-----------------" >> "$log_file"
    echo " " >> "$log_file"
    date >> "$log_file"
    echo " " >> "$log_file"
    echo "-----------------" >> "$log_file"
    echo " " >> "$log_file"
    # move consolidate log to daily file
    cat $tmp_log_file >> $log_file
    # remove temporary file
    rm -f $tmp_log_file
    # make sure virus files are right owners
    chown -R user:user $virus_vault Here is what it's based off, what I did for ClamAV to find new files and scan those only. #! /bin/bash
    if [[ $UID -ne 0 ]]; then sudo "$0"; exit 0; fi
    # Directories to scan
    scan_dir="/home/user/example.com/files"
    # Virus relocation folder
    virus_vault="/home/user/example.com/viruses/files"
    # Temporary file
    list_file=$(mktemp -t clamscan.XXXXXX) || exit 1
    # Create new log folder if it doesn't exist
    mkdir -p /home/user/example.com/viruses/logs/$(date +%Y-%m)
    # Location of log file
    log_file="/home/user/example.com/viruses/logs/$(date +%Y-%m)/clamscan-$(date +%Y-%m-%d).log"
    # Make list of new files
    if [ -f "$log_file" ]
    then
    # use newer files then logfile
    find "$scan_dir" -type f -cnewer "$log_file" -fprint "$list_file"
    else
    # scan last 5 minutes
    find "$scan_dir" -type f -cmin -5 -fprint "$list_file"
    fi
    if [ -s "$list_file" ]
    then
    # Scan files and remove (--remove) infected
    clamscan -f "$list_file" --move=/"$virus_vault" >> "$log_file"
    rm -f "$list_file"
    else
    # remove the empty file, contains no info
    rm -f "$list_file"
    fi
    exit 

    Quick comment...
    Sophos has 'decision caching' to speed up files that haven't changed since the last scan, while also allowing files to be re-checked against the latest threat definitions.

  • Using Automator to Copy Only New Files to a Destination Folder

    Hello,
    I need an AppleScript to copy a source directory (including all subfolders and files) to a destination folder, but one that checks for duplicate files and only copies files across from the source directory if they aren't already contained in the destination directory.
    I have a script that checks the files, but it only copies files from the source directory and ignores all subfolders and the files within those.
    Can anyone help?
    Thanks
    Reynell79

    red_menace wrote:
    You can create a Service workflow to get the folder(s).  The workflow would consist of actions to save the input items to a vatiable (so they can be refiltered), then get the input items, apply a filter, and move the resulting items - for example:
    Service receives selected folders in Finder
    Get Folder Contents
    Set Value of Variable { Variable: Original Items }
    Filter Finder Items { Find files where: kind is music }
    Move Finder Items { To: Automatically Add to iTunes }
    Get Value of Variable { Variable: Original Items } ( Ignore Input )
    Filter Finder Items { Find files where: kind is image }
    Move Finder Items { To: Album Artwork }
    ...repeat the Get/Filter/Move actions as needed for other filters
    Thanks, the "Set Value of Variable" concept is what I was missing. It almost works. The music files get moved, but then it says the workflow encounters a problem and the image files aren't being moved. I'm assuming it's an issue with steps 5-7. Thoughts?

  • Home Directory Permissions on New Files/Folders

    Problem: When a user creates a file or folder in the root of their home folder (ie. not in their Documents or other default folder) it is given "read" access to the "others" POSIX permission. So, anyone browsing the "users" folder on the network can view those files or folders. I would like to change this behavior so that when a user creates a file or folder, it is only read/write for the user and nothing for everyone else.

    umask is not really the correct thing to do in this case, as this resets the permissions for every file the user creates. Afaik, the umask setting has to be installed on every machine via the launchd-user.conf file (to contain simply: umask 002) (or whatever is appropriate for your facility), as umask is a property of the process, not the connection.
    What might work better for your problem is make the homedirs world and group non-readable. That way the user creates files within their homedirs and anywhere below, but everyone else can't read them regardless of the files' permissions because the directory itself is unreadable.

  • How can I download automatically only new images from my camera?

    Hello,
    I can not download only new images from my EOS 450D-camera with Elements 10-Photodownloafer (Mac os).
    Each time I use Photodownloader it downloads all images , also those that were downloaded preveously
    How can I set photodownloader?
    Thanks for your advices

    I share my card with my wife and she likes to download our images also on her PC, so erasing all images is not an option.
    It seems that earlier version of adobe photo downloader has the feature "copy only new files" , but V10 does not.
    Thanks for your answer
    Mikele
    Op 10-jun.-2012, om 15:33 heeft 99jon het volgende geschreven:
    Re: How can I download automatically only new images from my camera?
    created by 99jon in Photoshop Elements - View the full discussion
    Don’t you format the card in the camera after each download? That will wipe all images and prepare the card for a fresh shoot.
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4480409#4480409
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4480409#4480409. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Photoshop Elements by email or at Adobe Forums
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How to poll directory to check whether new file is added in plsql code

    How to poll directory to check whether new file is added in plsql code

    You can simply try opening that file for read in a loop (with some sleep in between). But in some OS (e.g. UNIX) file is accessible even if it is partially written. I suggest creating OK file (empty file with same name and OK as extension) after creating main file. This way PL/SQL code will be polling for OK file which means main file is completed.
    SY.

  • How do i delete Older files from the directory before create a new file?

    Hi,
    How do i delete older files in a particular directory,
    the senorio is count the number of .txt files in a directory and delete the older files if file count is more than 10. (if i add 11th file the very first file has to be deleted)
    i have written the code to count the files and delete , but it is deleting all the files instead of older file
    public class ExtensionFilter implements FilenameFilter {
      private String extension;
      public ExtensionFilter( String extension ) {
        this.extension = extension;            
      public boolean accept(File dir, String name) {
        return (name.endsWith(extension));
    public class FileUtils{
      public static void main(String args[]) throws Exception {
        FileUtils.deleteFiles("c:/countfile/", ".txt");
      public static void deleteFiles( String directory, String extension ) {
        ExtensionFilter filter = new ExtensionFilter(extension);
        File dir = new File(directory);
        String[] list = dir.list(filter);
        File file;
        if (list.length == 0) return;
        for (int i = 0; i < list.length; i++) {
          //file = new File(directory + list);
    file = new File(directory, list[i]);
    if ((list[i]).length()>=10)
         System.out.print(file + " deleted : " + file.delete());
    Thanks,
    Jamin Rosina                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    What your code is doing now, is deleting all filenames that are longer than 10 characters.
    Your problem lies in the line:
    if ((list).length()>=10)

  • Urgent!doubt in upload the file to a particular directory.

    Hi
    Actually i'm developing a site using JSP.
    Main concept of the project is the user should be
    able to access his files or dabases from anywhere
    in the world thru internet via intranet.
    i've placed upload option in my site.
    each user should b given a separate directory.
    can anyone tell me how to make the user to store
    the file in a particular directory(the one alloted to him).
    And to view the file, if the user enters the file name
    it should open the file in the particular format.
    i need the coding since i'm new to jsp.
    can anyone help me or refer any site tht can solve
    my problem?
    thanx in advance.

    I'd just answered a similar case. I believe this is what you are looking for;
    <%@ page contentType="MIME-Type; Charset=Character-Set" %>
    Read up on MIME-Type and Character-Set for info.
    Here some exmaple;
    By default:
    <%@ page contentType="text.html; Charset=ISO-8859-1" %>
    Show an MS Excel file;
    <%@ page contentType="application/vnd.ms-excel" %>
    or
    <%
    String mimeType = "application/vnd.ms-excel"
    response.seContentType(mimeType);
    %>
    Cheers

  • How to retrieve data from a read-only Excel file

    Hi Developers,
    I'm trying to retrieve data from a read-only Excel file. I used the same code that I used to retrieve data from a normal Excel file, but it can't work.
    My code is as followed:
    try
    InputStream KpExcel = new FileInputStream("kp.xls");
    HSSFWorkbook Kpwb = new HSSFWorkbook(KpExcel);
    HSSFSheet Kpsheet = Kpwb.getSheetAt(0);
    catch(Exception e)
    e.printStackTrace();
    System.out.println("Exception: "+e.getMessage());
    The error I received is as followed:
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:224)
    at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:160)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:210)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:191)
    at photoproductionsystem.IncomingWIPPanel.getKp(IncomingWIPPanel.java:118)
    at photoproductionsystem.IncomingWIPPanel.<init>(IncomingWIPPanel.java:76)
    at photoproductionsystem.TabbedDisplay.<init>(TabbedDisplay.java:47)
    at photoproductionsystem.Display.create(Display.java:73)
    at photoproductionsystem.Display.init(Display.java:44)
    at photoproductionsystem.Display.main(Display.java:229)
    Caused by: java.lang.ArrayIndexOutOfBoundsException
    at java.lang.System.arraycopy(Native Method)
    at org.apache.poi.hssf.record.UnknownRecord.<init>(UnknownRecord.java:62)
    at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:57)
    at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
    at org.apache.poi.hssf.record.Record.fillFields(Record.java:90)
    at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
    at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
    ... 15 more
    Can someone please help me with my problem? Thanks a lot in advance!

    Madeline wrote:
    how do I ask at Apache mailing list?I wonder why it seems to be a strange idea to some people to look at the software vendor's site for product support. :p
    http://poi.apache.org/mailinglists.html

  • How can I search a file system and only return newer files?

    Sorry the title didn't give me much room to work with. I'm writing a tool which needs to track all the files in an OS. What I'd like to do is make it so my program will only return files that have been modified/created since the last search to add to my program. I was wondering if there's an efficient way to do this other than checking each file's timestamps? Also is there a way to tell from a parent directory whether any files in its directory have been modified/created? I'm looking for ways for Windows and Linux.

    I have no problem checking timestamps but it can be rather time consuming doing this. I don't know if this is quicker but I'd like to sort by modified date and check the time stamps for newer timestamps than the last time I ran. This way if I hit a time stamp equal to my last run I know to stop there. I checked Windows and the folder does tell you whether any file was created/modified in it's directory. However, if a file is created in one of its children's directories it won't update the time stamp. It's unfortunate because I could've avoided the search at a higher level directory otherwise. Without this I'll have to walk the whole structure one way or another. I can still improve the speed but I can't make it as efficient as I'd like.

Maybe you are looking for

  • Change of Exchange rate in VA02

    Dear Experts We have sales order which is having around 5 line item and in that 1st line item alone has been invoiced in January and later items still not invoiced In the month of February, the invoice for 1st line item has been cancelled , so to avo

  • Connect SQL Server 2012 from Windows Server 2003 with native client 9.0

    Hi, I currently have a setup where ETL tool Ab Intio, running on a Linux server, connects to the SQL Server 2005 through a passthrough Wintel server with Windows Server 2003 OS using SQL server native client 9.0 Now I have the requirement to upgrade

  • Named Destinations with window.open

    I have a ColdFusion application that opens a reference document to a specific point of reference.  I had been using an html page with anchors for the reference document but would like to use PDF with named destinations. The code I am using is from a

  • DML in SQL Developer

    Hi, Can anyone please help me out why i can't add and modify records in the table directly? e.g. I click a table on left side its data will appear on the right side then when i am trying to update or add any new row over there its stopping me to do t

  • First pacman use conflicting files

    i just installed arch on my new machine, and im trying to install openbox and xorg. when i run pacman -S xorg it downloads, then complains about confilcting files. ./CHANGELOG exists in both 'glibc' and 'pcre' ./CHANGELOG exists in both 'glibc' and '