rename file

SOLVED

Hello,

I would like to be able to rename a file in [TMP]. I know I can do it with renameFile(PATH,PATH1)

Except the file name is random, let's say : IMPORTME2024 and I want to rename it IMPORTME

I tried a lot of stuff like this for exemple but it doesn't work and I'm really out of ideas.

Local Integer SUCCESS
Local Char PATH(250)

PATH=filpath("tmp", "IMPORTME%", "txt")
PATH1=filpath("tmp", "IMPORTME", "txt")

SUCCESS=renameFile(PATH,PATH1)
If SUCCESS=0
    Infbox "OK"
Endif

Is it even possible to get the file name ? I can get the path and properties thanks to filinfo but I can't find anything online on how to get the file name.

Thanks

  • 0

    Hi,

    Why do you want to rename the files ?

  • 0 in reply to Sadki

    Hello,

    I wish to import them with RELBANK through a recurring task.

    I can't find a way to import a file with dynamic name without renaming them with the name specified in the recurring task parameters.

    It won't let me use filename#.bak like any other import template.

    Hopefully my english is good enough for you to understand

  • +1 in reply to N2XF3
    verified answer

    ##--------------------------------------------------------------------------------------------------------------------------
    # Date de création           :   
    # Date de dernière MAJ       :   [00/00/0000]
    # Version                    :   [1]
    # Auteurs                    :   Nadir SADKI
    # --------------------------------------------------------------------------------------------------------------------------
    # Code spécifique            :   
    # Description                :   Listing a Rename File from folder  
    # --------------------------------------------------------------------------------------------------------------------------
    # Evolution                  :   [00/00/0000] - Auteur :[----------]
    # Description                :   
    ##--------------------------------------------------------------------------------------------------------------------------
    Local Char YOS : YOS = GOS
    Local Char YMACHINE : YMACHINE=adxmac(0)
    Local Char YLISTFIC(90)(9999), YDOSFIC(250), YFIC(250)
    Local Shortint YNBRFIC, YI
    LOCAL CHAR YPATH (250)
    #------------------------------------------------------------------------------------------------
    #
    #YDOSFIC='D:\Sage\ERPX3\folder\nameoffolder\tmp'
    #
    #--------------Ouverture Trace Serveur-------------------------------------------------------------------------------------    
    If GTRACE="" & !GSERVEUR
        Call OUVRE_TRACE("Rename file name Trace") From LECFIC
    Endif
    #--------------listing files from folder---------------------------------------------------------------------------
    Call LISFIC(YOS,YMACHINE,YDOSFIC,YNBRFIC,YLISTFIC) From SELFICREP
    For YI= 0 To YNBRFIC-1
        YFIC =YLISTFIC(YI)   
    infbox YFIC  
    #rename your file here (with condition or not) 
    
    Next
    

    Replace folder path with yours.

    This will allow you to list all the files available in the folder. You can add a condition according to your need to choose the files to rename...

  • 0 in reply to Sadki

    Wow this is perfect ! Thank you !

    How did you manage to find about this ?

    Call LISFIC(YOS,YMACHINE,YDOSFIC,YNBRFIC,YLISTFIC) From SELFICREP

    I can't find anything about SELFICREP ou LISFIC anywhere not even in the online help

  • 0 in reply to N2XF3

    I’m glad it helped you