1.

Solve : Batch File text export?

Answer»

Hello folks,

This is a long one but HEY!!!

I have some file coming in everyday via FTP. I NEED to get them into SQL Server. However, to get SQL to pick up the files I need to create a list of them. This is because the file names change everyday.

So, I have my bat file that list files in the directory but I then need to export this list to a txt file and save it.

Can anyone help. I'm getting beyond my programming experience here and we have no cash to get someone in!!!!!!!!!!

Cheers
 8-) Quote

I have my bat file that list files in the directory but I then need to export this list to a txt file and save it.

You didn't show your instruction that lists files.

I PRESUME DIR *.xxx
where xxx is the suffix of files you are interested in.

OK, try this

DIR *.xxx /b >MyDIR.txt

The "/b" is to get rid of extra stuff you don't need.

Mac
 
Thanks. That workd great.

Just got to do the sql BIT now.

Cheers Hey Mac,

Doh. When I import this to sql it seems I need to get the full directory listing ie...

G:\share\CRS\FTPDownloads\MyFilename.txt

The batch file I created is: dir G:\share\CRS\FTPDownloads/b>G:\share\CRS\CDSDataImport.txt
This just gives me MyFilename.txt

Do you know if this is possible to do?

CheersAdd the /s after the /b, this means - search subdirectories, but it will also give you the full path

DIR *.xxx /b /s >MyDIR.txt

If you do have subdirectories in this folder, then the files in there will be listed too.
Graham
Cheers Graham. You are a pro!!!!!!!!!!


Discussion

No Comment Found