Operating System - Microsoft
1748216 Members
3598 Online
108759 Solutions
New Discussion юеВ

transfer just last generated files using ftp from win machine

 
index
Occasional Contributor

transfer just last generated files using ftp from win machine

Hi all,

after connecting to windows ftp server, I would like to transfer files that are last generated, I mean last ones according date. In linux/unix I know it is possible to do something like ls -s | awk '{ print $1, $ time field } ' and select files for transfer. But I do not know to do the same on windows after connecting. I google-ed, but still did not find some solution.
Also, when I after connecting to win machine issue cd c:\ I got, ftp> cd c:/
550 c:/: The filename, directory name, or volume label syntax is incorrect
Can you suggest, what is wrong with this command, it is stated in microsoft help page as
correct sintax.

Thanks in advande,

with regards,

3 REPLIES 3
Change_happens
Honored Contributor

Re: transfer just last generated files using ftp from win machine

Hi index ;-),
In windows you can use script which are also same/more powerful as script on linux.
for example you wanna list all file creation list write a file double click to run:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='c:\Logs'} Where " _
& "ResultClass = CIM_DataFile")

For Each objFile In FileList
strDate = Left(objFile.CreationDate, 8)
Wscript.Echo strDate
Next
//++++++++++++++++++++++++++++++
It will display all dates you can do manipulation and anything.

Now your ftp issue?
Did you setup a FTP server and client?
files you are transferring need ftp service on target too?
index
Occasional Contributor

Re: transfer just last generated files using ftp from win machine

Thanks for update. I resloved problem related to ftp, I can transfer files form client to server and vice-versa. Now, I am playing to find some way to transfer just last generated file from script in win. scheduler. Any idea is welcome.

With regards,
Change_happens
Honored Contributor

Re: transfer just last generated files using ftp from win machine

see win script is very flexible and very powerful; even u don't need ftp to copy over network. anyways up to u.
see this exapmple you can run SQL queries here:
+++++++++++++++++++++++++++++++++
Set objLogParser = CreateObject("MSUtil.LogQuery")
Set objInputFormat = CreateObject("MSUtil.LogQuery.FileSystemInputFormat")
objInputFormat.Recurse = 0

Set objOutputFormat = CreateObject("MSUtil.LogQuery.NativeOutputFormat")
objOutputFormat.rtp = -1

strQuery = "SELECT Name, CreationTime FROM 'C:\Scripts\*.*' " & _
"WHERE NOT Attributes LIKE '%D%' ORDER BY CreationTime"
objLogParser.ExecuteBatch strQuery, objInputFormat, objOutputFormat
++++++++++++++++++++++++++++++++
which can sort ur directory to creation date. now u can write query to list only file which are less than a specified date. and put them in a array and copy those.

+++++++++
To copy over network:
Set objNetwork = CreateObject("Wscript.Network")
objNetwork.MapNetworkDrive "Z:", "\\atl-fs-01\Public" +++ map the drive

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Scripts\Test.txt", "Z:\" +++ copy files

objNetwork.RemoveNetworkDrive "Z:" ++ disconnect again.
+++DONE

Hope u will play more with script and get ur work done as well as learnings.