0

I am working with the Informatica platform that only allows me to use batch files. I am currently producing a list of file names with the command dir /b /a-d

850_B_4545703_.txt
850_B_003029660_.txt
850_B_069029548_.txt
850_B_188789_.txt
850_C_ENT_1712865_.txt
850_C_ENT_1712871_.txt
850_C_1712877_.txt

But for Informatica to use this list to locate files I have to add path used in the flat file connection which is

\\jdeappp03\EDI\

So what I am trying to achieve is a batch file that will output the following:

\\jdeappp03\EDI\850_B_4545703_.txt
\\jdeappp03\EDI\850_B_003029660_.txt
\\jdeappp03\EDI\850_B_069029548_.txt
\\jdeappp03\EDI\850_B_188789_.txt
\\jdeappp03\EDI\850_C_ENT_1712865_.txt
\\jdeappp03\EDI\850_C_ENT_1712871_.txt
\\jdeappp03\EDI\850_C_1712877_.txt

I tried using dir /s/b *.txt but this give the absolute path which my setup of Informatica is not able to use to find the files.

Is there a way to get my desired result with a batch file?

2 Answers2

2

You could use the following command in a batch file:

for /f "delims=" %%a in ('dir /b /a-d <PATH>') do (echo \\jdeappp03\EDI\%%a)

Using a for loop around the command allows you to iterate through its output and save it in the variable %%a. Everything you want to do during that iteration comes after do.

You only need parentheses after do if you want to use linebreaks for readability.

Use for /? in the Windows cmd to learn more about the for command.

0

A shorter option would be:

for %%i in ("D:\Path\*.txt")do echo \\jdeappp03\EDI\%%~nxi
Io-oI
  • 9,237