id="info"

Question

Locked

FTP / VBScript

By Matt H ·
Hi All

I have a problem with a customer that continually sends us files with a comma in the filename but will not change their conventions. The comma isn't always in the same place though. And most of the time not there at all. I currently have a dos batch file that is run by the ftp server when a file is uploaded, but naturally it's missing these files, can anyone suggest a way of removing the commas? I'd like to use VBS but I'm rubbish at it - trying to learn again though. I'm using ncftp to do the actual file transfer to another internal ftp server (it works and is very fast).

Thanks

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

a little more specific

by lowlands In reply to FTP / VBScript

Do I understand it correctly that the filename itself has a comma in it? So something like <b>text,file.txt</b>.

Second question, what does the batch file on your ftp server do?

And this little script would rename any files with <b>1</b> comma in it to the same name, but without the comma. This example checks all temp dirs on the system, so change that to whatever directory your files are in.
<br></br>
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService. _
ExecQuery("Select * from CIM_DataFile where Path = '\\TEMP\\'")

For Each objFile in colFiles
If instr(objFile.Name, ",") <> 0 Then

arrFileName = Split(objFile.Name, ",")
strNewFileName = arrFileName(0) & arrFileName(1)
Wscript.Echo objFile.Name
wscript.echo strNewFileName
errResult = objFile.Rename(arrFileName(0) & arrFileName(1))

end if
Next

Collapse -

This script will rename the files so that the commas are removed.

by MartMan In reply to FTP / VBScript
Back to Networks Forum
3 total posts (Page 1 of 1)  

Hardware Forums