Finding newest file in given directory

I have a program that needs to automatically take data from a text
file made earlier. There are several text files in a certain
directory, and i need the program to take the newest file. The text
files are labeled as so:
mm-dd-yyyy-time.txt
ex: 12-21-2001-0813.txt
now, is there a way to read file names in a directory? or, does
labview have a function that can return a file name given "modified"
date?
any suggested plan of attack is greatly appreciated.
[email protected]

In LV6 (i'm not sure for earlier versions) in File I/O - > Advanced File Functions palette, you have "List Directory" and "File/Directory Info" ... so, exactly what you are looking for.
Hope this helps
p.s.: a suggestion would be the yyyy-mm-dd-time.txt format ... especially if you are using the explorer to access them too

Similar Messages

  • Issue related finding a file in a directory

    Hi
    I am trying to find a file from a directory and print it on screen using only first half of the file name.
    like I have files you_are_best.pdf,you_are_geneious.pdf, we_are_best.pdf. Now I need to find the pdf from the directory having name you_are.
    can any one help me in solving this issue.

    Sukant_at wrote:
    Hi
    I am trying to find a file from a directory and print it on screen using only first half of the file name.
    like I have files you_are_best.pdf,you_are_geneious.pdf, we_are_best.pdf. Now I need to find the pdf from the directory having name you_are.
    can any one help me in solving this issue.Read this.

  • Find the File name from directory

    Hi Experts,
    My Scenario is:
    Pick the file from the Directory, Based on the file name, get the Q information from R/3 system and place the file into MQ.
    My Question is : How can I get the file name?, any one please guide me..
    Thanks for your help,
    Thanks,
    SR

    HI SR
    You need to enable the Adapter-Specific Message Attributes
    enable the FileName under this. Enabling this will allow to have this parameter as XI header
    You can check this value is generated or not using SXMB_MONI -> Inbound message -> SOAP header  -> Dynamic Configuration.
    This will be captured under http://sap.com/xi/XI/System/File name =  FIleNameu201D
    Now code given by Anand above will allow you to use this FileName in mapping. Based on this you can check R/3 system for relevant file.
    Hope this make you confortable with filename concept
    Thanks
    Gaurav

  • Webgate installation - not able to find .cgi file in bin directory

    Hi friends,
    I am trying to install webgate on ohs server (after webpass installation). But as told in installation document for webgate, we need to configure the webgate by giving relative path to dll or cgi file in bin directory.
    But when I tried to search .cgi file in bin directory, there is no cgi file there, there is only webgate.dll file.
    Please tell me what exactly is the issue I am facing here?
    Thanks in Advance,
    Amit

    Hi,
    Let me know which document you are following. While installing webgate, we need to provide the path configuration file of webserver. In your case, it is httd.conf.
    Regards
    GK Goalla

  • Find newest file in folder

    Is there a way to only pull the newest (most current time stamp) file out of a folder?
    Cheers!
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

    Thank you for the quick reply!
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • File in target directory?

    Hi Friends,
    The audit log says that the message is delivered but i cannot find the file in target directory.Does this indicate that the file is picked by the receiver system,if yes then once the file is picked the file is deleted from the target directory?
    Note-The "file construction mode" is set as create.
    Regards,
    Suresh.

    Hi Suresh
    Check for the SXMB_MONI as suggested above if you have success message.
    Moreover
    ,if yes then once the file is picked the file is deleted from the target directory?
    When the audit log says message delivered it will be delivered to target directory.
    Now if your scenario is file to file message can be deleted from source directory and not from target directory.
    Thanks
    Gaurav

  • Robocopy copie only the the newest file

    Hello,
    I want to copy only the newest file from source directory using robocopy 
    Robocopy "N:\source" "H:\bak" "Nss_GT_??.bak" /XO
    but I copy all files with the same pattern. 
    How can I do it?

    Hello,
    I want to copy only the newest file from source directory using robocopy 
    Robocopy "N:\source" "H:\bak" "Nss_GT_??.bak" /XO
    but I copy all files with the same pattern. 
    How can I do it?
    RoboCopy has no "newest" argument.   "Newest" is ambiguous.  "Newest" compared to what?
    Post RoboCopy questions in the platform forum for the OS you are using.  They work with the Windows utilities.  This is a scripting forum for Admin scripting. RoboCopy is not a script.
    ¯\_(ツ)_/¯

  • I need to find a method of opening and then saving to PDF every Framemaker document in a given directory. Can fmbatch be used to do this?

    Does anyone have an fmbatch file which could find all the .fm files in a given directory, open them with FrameMaker and the save them as a PDF file.
    Or
    Can someone show me the commands required to do that?

    Of you could just make a quick temporary book including all the .fm files
    in the directory and print them to PDFs (no, not SaveAs) and specify
    individual files as output.
    Art Campbell
              [email protected]
      "... In my opinion, there's nothing in this world beats a '52 Vincent and
    a redheaded girl." -- Richard Thompson
                                                          No disclaimers apply.
                                                                   DoD 358
    I support www.TheGrotonLine.com, hyperlocal news for Groton MA.
    On Tue, Jun 10, 2014 at 5:04 PM, guessinggame <[email protected]>

  • What is the maximum number of files that Finder can display in a directory?

    When displaying systems in an Active Directory domain, Finder only displays some of the systems.
    I presume that Finder is treating the list of SMB/CIFS systems as if they were entries in a file directory. The number of systems that should appear in the list is around 10,000 but only about half of these are displayed in Finder.
    Is there a way to increase the number of systems displayed in Finder?

    Yes, I am working with a Windows Active Directory domain.
    When using Finder>Network> to display systems in an Active Directory domain, it fails to display all of the systems. Is there a Finder limitation that causes this?
    When the system was originally brought online, only the local systems that were members of the Active Directory domain were displayed. Over time, the number of systems that have been "discovered" has increased. The entries are maintained in ascending alphabetical order. Currently, only systems with names beginnig with A through M are listed.
    This creates a bit of a problem for our Technical Publications group as all of the systems in our facility start with the letter T.
    Does Finder have a limit on how many entries that it can display for a given directory?
    Is the list of Active Directory systems being maintained in memory and, hence, limited by memory resources?
    Is there a way to filter the list?

  • Showing all files of a given directory

    I'm trying to write a class that shows me all files of a given directory. When a run the class without parameters, everything seems to work fine, however, when I use a parameter that contains the directory, I get the following error:
    java.lang.NullPointerException
         at be.hogelimb.ti.fundamentals.io.IOProgr4.<init>(IOProgr4.java:25)
         at be.hogelimb.ti.fundamentals.io.IOProgr4.main(IOProgr4.java:43)
    Exception in thread "main"
    this is my class without parameters:
    public class IOProgr4 {
    public IOProgr4(){
    File dirName = new File("C:\\Documents and Settings\\FirstName LastName\\My documents\\test");
         if (dirName.exists()){
         if (dirName.isDirectory()){
         File[] dirFiles = dirName.listFiles();
         for (int i = 0; i<dirFiles.length; i++){
         System.out.println(dirFiles);
         else{
         System.out.println("dirName is not a directory");
         else{
         System.out.println("Can'f find directory");
         public static void main(String args[]){
              new IOProgr4();
    You see, it's a very simple class.
    This is my class with parameters :
    public class IOProgr4 {
    String dirString;
    public IOProgr4(String dirString){
    this.dirString = dirString;
    File dirName = new File(dirString);
    if (dirName.exists()){
    if (dirName.isDirectory()){
         File[] dirFiles = dirName.listFiles();
         for (int i = 0; i<dirFiles.length; i++){
         System.out.println(dirFiles[i]);          
         else{
         System.out.println("dirName is not a directory");
         else{
         System.out.println("Can't find directory");
    public static void main(String args[]){
    String dirString = "";
    for (int i = 0; i < args.length; i++){
    dirString += args[i] + " ";
    new IOProgr4(dirString);
    I'm working with Eclipse and my parameter string is the same as the String I've written in the first class, and it's also recognized as a directory. Can anyone tell me why this doesn't work?
    Thanks in advance!!!

    I'm working with Eclipse and my parameter string is
    the same as the String I've written in the first
    class...In the end, it has nothing to do with whether you've hard-coded the directory name versus taken it as a parameter. It must not have been the same value, or it would have worked the same. So your problem lies elsewhere - however, you were given a nice stack trace pointing out the line in your code where it happened. Are you not familiar with a little concept known as debugging?

  • When I download a page a message says cannot find zip file directory

    When I try to download a page a message appears after the download time saying in part that "cannot find zip file directory". This message appears on all downloads I attemp.

    Here are typical layouts for the iTunes folders:
    If you have upgraded from version 8 (or earlier) to iTunes 9 (or later) at some point, then your media folder (everything inside the red outline) may still be called iTunes Music instead of iTunes Media. The extra Music folder inside the media folder is used if you have allowed iTunes to Upgrade to iTunes Media Organization (iTunes 9) or used File > Library > Organize Library > Reorganize files in the folder "<Media Folder>" (iTunes 10). Depending on your choices for Keep iTunes Media folder organized and Copy files to iTunes Media folder when adding to library plus a little bug in which one build changed the name of the file storing the choice of layout it is quite easy for some of your files to be organized according to one layout and some the other.
    It is possible that in the upgrade to Lion iTunes has been installed with the current default options while your library is based on an older structure. Use Get Info. on a missing track, click cancel when asked to locate it and look at the path given on the summary tab. Now look for the actual file with Finder. Post both paths back here and we can try to make sense of the problem.
    tt2

  • So whenever I try to download the newest itunes file it won't let me finish the install process because I'm missing the "Itunes.msi" file whatever that is and I've done some searches but I cannot find the file. Anyone know what to do?

    So whenever I try to download the newest itunes file it won't let me finish the install process because I'm missing the "Itunes.msi" file whatever that is and I've done some searches but I cannot find the file. Anyone know what to do?

    you can try this thread maybe? https://discussions.apple.com/message/16217061#16217061

  • How can I get file list for a given directory?

    Hi,
    How can I get file list for a given directory? Is there a function?
    Thanks.

    Hi friend,
    Try this sample report. It displays all files in a directory.
    While executing give some directory name in input. ex:  C:\
    Mention file type in filter parameter. ex: *.DOC
    REPORT ztests.
    DATA : file_table LIKE TABLE OF sdokpath WITH HEADER LINE .
    DATA : dir_table LIKE TABLE OF sdokpath WITH HEADER LINE .
    PARAMETERS:p_dir(50) TYPE c.
    CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
      EXPORTING
        directory  = p_dir
        filter     = '*.DOC'
      TABLES
        file_table = file_table
        dir_table  = dir_table
      EXCEPTIONS
        cntl_error = 1
        OTHERS     = 2.
    LOOP AT file_table .
      WRITE:/ file_table-pathname.
    ENDLOOP.
    Might be helpful...
    Thanks.....
    Edited by: Guest77 on Feb 11, 2009 5:30 AM

  • Functional module to get the File from a given Directory

    Hi all,
    I am using a FM name 'subst_get_file_list' to get the file from a given directory but it is accepting only 40 Character length file only my requirement is to accept file name other than 40 char,
    give me good sugestion
    regards
    paul

    Hi Paul,
    Check the Function Module Gayathri has given. ie. 'SO_SPLIT_FILE_AND_PATH'.
    In the exporting parameter FULL_NAME , give the path name and in the importing parameter stripped_name , you will get the filename.
    Check this code.
    REPORT ZSHAIL_SPLITFILE.
    data: it_tab type filetable with header line,
          gd_subrc type i.
    tables: rlgrap.
    data: path type string,
          file_name type string.
    parameters file_nam type rlgrap-filename .
    data: user_act type i.
    at selection-screen on value-request for file_nam.
    CALL METHOD cl_gui_frontend_services=>file_open_dialog
      EXPORTING
        WINDOW_TITLE            = 'select a file'
       DEFAULT_EXTENSION       = '*.txt
        DEFAULT_FILENAME        = ''
        FILE_FILTER             = '*.txt'
        INITIAL_DIRECTORY       = ''
        MULTISELECTION          = abap_false
       WITH_ENCODING           =
      CHANGING
        file_table              = it_tab[]
        rc                      = gd_subrc
        USER_ACTION             = user_act
       FILE_ENCODING           =
      EXCEPTIONS
        FILE_OPEN_DIALOG_FAILED = 1
        CNTL_ERROR              = 2
        ERROR_NO_GUI            = 3
        NOT_SUPPORTED_BY_GUI    = 4
        others                  = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    if user_act = '0'.
    loop at it_tab.
    file_nam = it_tab-filename.
    endloop.
    endif.
    path = file_nam.
    CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
      EXPORTING
        full_name           = path
    IMPORTING
       STRIPPED_NAME       = file_name
      FILE_PATH           =
    EXCEPTIONS
      X_ERROR             = 1
      OTHERS              = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    at selection-screen.
    message i001(zmess) with file_name.
    Regards,
    SP.

  • Create a Blank Text file if it does not exist in a Given Directory

    Hi,
    I would like to check if text file in a given folder exists or not if not then create a blank text file in a given directory. I was checking File system task, it has options to create directory and move files, copy files but not creating files.
    How can I create a blank text file in a given directory in SSIS using script task or any other way.
    Many thanks.
    Mustafa
    MH

    Thanks Saravana for your help. I am using the following code in the script Task two
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.IO
    Imports System.Object
    Imports System.Security.Cryptography
    Imports System.IO.Compression
    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
    <System.CLSCompliantAttribute(False)> _
    Partial Public Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    Enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum
    ' The execution engine calls this method when the task executes.
    ' To access the object model, use the Dts property. Connections, variables, events,
    ' and logging features are available as members of the Dts property as shown in the following examples.
    ' To reference a variable, call Dts.Variables("MyCaseSensitiveVariableName").Value
    ' To post a log entry, call Dts.Log("This is my log text", 999, Nothing)
    ' To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, True)
    ' To use the connections collection use something like the following:
    ' ConnectionManager cm = Dts.Connections.Add("OLEDB")
    ' cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;"
    ' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    ' To open Help, press F1.
    Public Sub Main()
    ' Add your code here
    Dim inputFile As String
    Dim outputFile As String
    Dim encoding As String
    Dim PrivateKeyInXML As String
    inputFile = Dts.Variables("Item1Path").Value.ToString()
    outputFile = Dts.Variables("OutputFile1").Value.ToString()
    encoding = Dts.Variables("Encoding").Value.ToString()
    PrivateKeyInXML = Dts.Variables("PrivateKey").Value.ToString()
    Dim CallCryptoReader As CryptoReader = New CryptoReader(inputFile, outputFile, encoding, PrivateKeyInXML)
    Dts.TaskResult = ScriptResults.Success
    End Sub
    Public Class CryptoReader
    Private _FileStream As FileStream
    Private _CryptoStream As CryptoStream
    Private _ZipStream As GZipStream
    Private _RSAPrivateKeyinXML As String
    Dim _CryptoAgent As New System.Security.Cryptography.AesCryptoServiceProvider
    'System.Text.Encoding
    Sub New(ByVal inputFile As String, ByVal outputFile As String, ByVal encoding As String, ByVal PrivateKeyInXML As String)
    _RSAPrivateKeyinXML = PrivateKeyInXML
    'Create the crypto agent
    _CryptoAgent = AesCryptoServiceProvider.Create
    '''''''_CryptoAgent.GenerateIV()
    '''''''_CryptoAgent.GenerateKey()
    'Open cypher text for reading in
    _FileStream = New FileStream(inputFile, FileMode.Open)
    ReadHeaderFromFile() 'write out aes key to header
    'Create the stream to decrypt the AES part of the file
    _CryptoStream = New CryptoStream(_FileStream, _CryptoAgent.CreateDecryptor, CryptoStreamMode.Read)
    _ZipStream = New GZipStream(_CryptoStream, CompressionMode.Decompress)
    'setup complete - run decrypt to unprotect the rest of the file
    DecryptFile(outputFile)
    Flush()
    Close()
    Dispose()
    End Sub
    Public Sub Close()
    _CryptoStream.Close()
    _ZipStream.Close()
    _FileStream.Close()
    End Sub
    Public Sub Dispose()
    _CryptoStream.Dispose()
    _ZipStream.Dispose()
    _FileStream.Dispose()
    End Sub
    Public Sub Flush()
    _CryptoStream.Flush()
    _ZipStream.Flush()
    _FileStream.Flush()
    End Sub
    Private Sub ReadHeaderFromFile()
    'Read the AES Key (Protected by RSA Key) and then the IV
    Dim UnProtectedAESKey() As Byte
    Dim buffer(_CryptoAgent.BlockSize - 1) As Byte
    'Read in protected AES Key
    _FileStream.Read(buffer, 0, _CryptoAgent.BlockSize)
    'Decrypt AES Key
    UnProtectedAESKey = releaseKeyFromRSA(buffer)
    _CryptoAgent.Key = UnProtectedAESKey
    ReDim buffer(_CryptoAgent.IV.Length - 1)
    'get IV
    _FileStream.Read(buffer, 0, _CryptoAgent.IV.Length)
    _CryptoAgent.IV = buffer
    End Sub
    Public Sub DecryptFile(ByVal outFilePath As String)
    Dim outFile As New FileStream(outFilePath, FileMode.Create)
    Dim count As Integer = 1024
    Dim buffer(count - 1) As Byte
    Do Until count = 0
    count = _ZipStream.Read(buffer, 0, count)
    outFile.Write(buffer, 0, count)
    Loop
    outFile.Flush()
    outFile.Close()
    outFile.Dispose()
    End Sub
    Private Function releaseKeyFromRSA(ByVal key() As Byte) As Byte()
    Debug.Print("Protected AES Key - " & key.ToString)
    Dim cspParam As New CspParameters()
    Dim RSA As New RSACryptoServiceProvider(1024, cspParam)
    'private
    RSA.FromXmlString(_RSAPrivateKeyinXML)
    Dim decryptedAsByte() As Byte = RSA.Decrypt(key, True)
    Debug.Print("Release RSA - " & System.Text.Encoding.ASCII.GetString(decryptedAsByte))
    Return decryptedAsByte
    End Function
    End Class
    End Class
    I am using the Outputfile1 variable. this is the variable where the path of the file will come which was created in the previous script task. In this task i got the exception that it is alread in use.
    MH

Maybe you are looking for