Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - Microsoft
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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.