VB Script - renaming of a file RRS feed

  • Question

  • Hi Guys,

    I'm no coding fundi hence my question, hope you can help.

    Busy with an integration project whereby SAP and Active Directory merges using middleware. The resultant is a flat file (.csv) which is scheduled to import daily into an Application. Much more involved but irrelevant to my query. 

    Unfortunately the Application schedule does not allow for wildcard entries for import. The flat files are placed on a network share and is daily incremented/updated at 06h00; this update number i.e 001 is reflected in the filename, and obviously changes daily.

    long story short, is it possible to rename the latest file to a specific filename and the schedule configured to point to that specific filename ?

    Please advise

    • Edited by Nigel68 Monday, July 31, 2017 11:22 AM
    • Moved by Bill_Stewart Wednesday, September 13, 2017 9:31 PM This is not "scripts on demand"
    Monday, July 31, 2017 8:26 AM

All replies

  • Don't use VBScript anymore. Start with Powershell! 

    Quick & dirty:

    Get-ChildItem -Path 'C:\sample\*' -Filter *.* | 
        Sort-Object -Property LastWriteTime | 
            Select-Object -Last 1 | 
                Rename-Item -NewName 'the desired name'

    Of course you have to adjust the path, filter and desired name.  ;-)

    Have fun!

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    • Edited by BOfH-666 Monday, July 31, 2017 9:38 AM
    Monday, July 31, 2017 9:37 AM