4 Replies Latest reply on Sep 26, 2021 9:00 AM by Jharana Patra

    Dynamic source file name in double quotes

    Mario Masetto New Member



      I am trying to import a dynamic set of csv files into a database table.

      The list of files should be return by a command batch file. The code for this command file I have worked out so far is:


      @echo off

      cd C:\Users\Public\

      for /f "delims=" %%x in (LastExecution.txt) do set vardate=%%x

      forfiles  /m *_??_??_????.csv /d +%vardate% /c " cmd /c echo  @FILE"


      which gives the file names enclosed in double quotes.


      But the mapping does not seem to accept the double quotes!!!! The execution returns this error:


      FR_3000 Error opening file [C:\Users\Public\"170802_17_09_2021.csv"]. Operating system error message [The system cannot find the file specified.].


      If I removed the double quotes with this code:


      @echo off

      cd C:\Users\Public\

      for /f "delims=" %%x in (LastExecution.txt) do set vardate=%%x

      for /f %%i in ('forfiles  /m *_??_??_????.csv /d +%vardate% /c " cmd /c echo  @FILE" ') do @echo %%~i


      the mapping works but I cannot load files that contain spaces in their names!

      Unfortunately I have such files to load and I cannot change their names.


      Does anyone have a solution?