|
Answer» Hello, does anyone know if there is a SWITCH that can be used with the copy command to update the Date Modified to the current datetime on the destination?No there is not. I just found something on the Microsoft site....have you seen copy /b?This does not seem to be working for me but this is what I found on Microsoft.....
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true
... Changing the time and date of a file
If you want to assign the current time and date to a file without modifying the file, use the following syntax:
copy /b Source+,, I stand corrected.
Code: [Select]C:\Program Files\gzip\bin>dir znew Volume in drive C is WinXP Volume Serial Number is FC8E-1A32
Directory of C:\Program Files\gzip\bin
03/04/2007 10:59 4,956 znew 1 File(s) 4,956 bytes 0 Dir(s) 3,556,474,880 bytes free
C:\Program Files\gzip\bin>copy /b znew+,, 1 file(s) copied.
C:\Program Files\gzip\bin>dir znew Volume in drive C is WinXP Volume Serial Number is FC8E-1A32
Directory of C:\Program Files\gzip\bin
12/11/2009 20:19 4,956 znew 1 File(s) 4,956 bytes 0 Dir(s) 3,556,474,880 bytes FREEI have been testing this:
copy /b g:\WO_CompletionFinal_Trigger.txt \\'ServerName'\CFCSourcing\WO_CompletionFinal_Trigger.txt
Any suggestions as to why this does not work?
Does this work?
Code: [Select]copy /b g:\WO_CompletionFinal_Trigger.txt \\'ServerName'\CFCSourcing Do you have write access permission on the target drive?
Yes. I have been placing other files there as well and the Date Modified on the destination retains the create date (Date Modified) from the source. I was thinking I had something wrong syntactically?You missed out the plus sign and the two commas.
I think you would have to apply the copy /b source+,, syntax once the file has been copied over like this
so try this
Code: [Select]copy g:\WO_CompletionFinal_Trigger.txt \\'ServerName'\CFCSourcing\WO_CompletionFinal_Trigger.txt copy /b \\'ServerName'\CFCSourcing\WO_CompletionFinal_Trigger.txt+,, KISS
D:\$A>copy junk + "" test /b
junk keeps date test has today's date Both are same size no space between quotes This is in the XP command ine I really appreciate the feedback Salmon, unfortunately the "copy /b \\'ServerName'\CFCSourcing\WO_CompletionFinal_Trigger.txt+,," added to the batch file did not work.
I have the destination mapped on the source computer and am viewing the files with Explorer. Do you think its just a Windows 'thing' that shows the same date on the same file? I have asked for someone to verify the Date Modified on their side (destination) to see if it is in fact the same, or later as a result of my testing (and I just can't see it on the destination side while looking at it from the source). Thankfully other processes are dependent upon its EXISTENCE only and not the date it was placed on the destination. But I think that it would still be useful, short of creating a time log.
Geek-9pm,
How would I apply the syntax you provided to this statement?...
copy /b g:\WO_CompletionFinal_Trigger.txt \\'ServerName'\CFCSourcing\WO_CompletionFinal_Trigger.txt
This statement works, however the date is not changing on the destination, (from what I can TELL...see above) Here is the model: copy source + "" target /b
Long stings of text make it hard for me to DEBUG. The computer is faster taht me, so let it do some of the work.
Inside a batch I would put edit: correction made on code lines below Code: [Select]set source=g:\WO_CompletionFinal_Trigger.txt set target=\\'ServerName'\CFCSourcing\WO_CompletionFinal_Trigger.txt copy %source% + "" %target% /b
Well I wish I could tell you it worked but it did not.
I appreciate the responses!corrections made above.Quote from: SQLGuy on November 12, 2009, 12:45:53 PM Hello, does anyone know if there is a switch that can be used with the copy command to update the Date Modified to the current datetime on the destination?
You can do it natively through vbscript. assuming you already map to e:\
Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments strFileToCopy = objArgs(0) 'file to copy strDestination = objArgs(1) 'copy to destination strComputer = "10.10.10.10" 'your remote computer IP Set objShell = CreateObject("Shell.Application") Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set ColDate = objWMIService.ExecQuery("Select * from Win32_LocalTime") ' Get remote computer date and time For each strDate in ColDate strDateToChange = CDate(strDate.Day & " " & strDate.Month & " " & strDate.Year) strTimeToChange = CDate(strDate.Hour & ":" & strDate.Minute & ":" & strDate.Second ) Next ' copy the file over to destination objFS.CopyFile strFileToCopy,strDestination & "/" & strFileToCopy Set objFolder = objShell.NameSpace(strDestination) ' set the file time stamp to that of the remote objFolder.Items.Item(strFileToCopy).ModifyDate = strDateToChange & " " & strTimeToChange Set objWMIService = Nothing Set objFolder = Nothing Set objShell = Nothing usage: Code: [Select]c:\test> cscript /nologo modifydate.vbs "file.txt" "e:\destination"
|