Need the Import Scripts | file name append with date & time stamp

Hi Guys,

 

I need import action batch script to take the file name with (Date & Time details) and every time same file name keep on changing with updated date & time stamp.

 

Example: File name : Import_File_Name_30062020_0930.csv

and next time the file name to run the same import scripts is below:

File name:  Import_File_Name_01072020_1030.csv

 

Thanks in advance

 

 

Best Answers

  • xrprasadx
    Answer ✓

    ================Working Script=================================

     

    @Echo off
    rem This example loads a source text file and runs an Anaplan import into a module.
    rem For details of how to configure this script see doc\Anaplan Connect User Guide.doc

    set AnaplanUser="username:password"
    set WorkspaceId="Type WorkspaceID"
    set ModelId="Type ModelID"
    set DumpName="Client Location for Dumping the Errored data from Import"
    set Chunksize=1

    for %%F in (E:\anaplan\filename_*.csv) do set filename=%%F
    echo %filename%
    pause
    set Operation==-file "File_Name.csv" -put "%filename%"
    set Operation=-service "https://api.anaplan.com" -auth "https://auth.anaplan.com" -file "File_Name.csv" -put "%filename%" -process "ProcessName" -execute -output "C:\Desktop\Archive\folderName"

    rem *** End of settings - Do not edit below this line ***
    setlocal enableextensions enabledelayedexpansion || exit /b 1
    cd %~dp0
    if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
    set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
    @Echo %Command%
    cmd /c %Command%

    move E:\anaplan\filename_*.csv "C:\Desktop\Archive\"
    pause

    =========================================================================================

Answers

  • @xrprasadx 

     

    Haven't done any such thing in the past. I am not even certain if that is the possibility in Integration activities as Anaplan Connect will look for the same file in the server. I might be wrong here but let's see what others have to say. @ben_speight can you help here.

    .

  • Hey,

     

    just a thought, what if you write script to rename file from Import_File_Name_30062020_0930.csv to Import_File_Name.csv in the same path before Anaplan connect script kicks in. 

     

    mv src_name dest_name 

  • If you specify a server file using -file, the server file name is completely independent of the local file name (if you don't, the server file defaults to the local file name). If you use a YYYYMMDD format for the name, it is easier to sort them and find the most recent.

  • Thankyou
  • @xrprasadx 

    Yes that can also work, in the end Anaplan Connect will look for a fixed name