Home / Microsoft / Microsoft DOS / Need help using the copy command
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: Need help using the copy command  (Read 408 times)
SQLGuy
Topic Starter
Greenhorn



Posts: 7


« 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?
IP logged
Salmon Trout
Prodigy



Thanked: 501
Posts: 7,363

Computer: Specs
Experience: Guru
OS: Linux variant

1
« Reply #1 on: November 12, 2009, 01:02:23 PM »

No there is not.
IP logged

SQLGuy
Topic Starter
Greenhorn



Posts: 7


« Reply #2 on: November 12, 2009, 01:03:46 PM »

I just found something on the Microsoft site....have you seen copy /b?
IP logged
SQLGuy
Topic Starter
Greenhorn



Posts: 7


« Reply #3 on: November 12, 2009, 01:12:44 PM »

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+,,
IP logged
Salmon Trout
Prodigy



Thanked: 501
Posts: 7,363

Computer: Specs
Experience: Guru
OS: Linux variant

1
« Reply #4 on: November 12, 2009, 01:19:46 PM »

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 free
IP logged

SQLGuy
Topic Starter
Greenhorn



Posts: 7


« Reply #5 on: November 12, 2009, 01:32:42 PM »

I 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?

IP logged
Salmon Trout
Prodigy



Thanked: 501
Posts: 7,363

Computer: Specs
Experience: Guru
OS: Linux variant

1
« Reply #6 on: November 12, 2009, 01:57:37 PM »

Does this work?

Code: [Select]
copy /b g:\WO_CompletionFinal_Trigger.txt \\'ServerName'\CFCSourcing
Do you have write access  permission on the target drive?

IP logged

SQLGuy
Topic Starter
Greenhorn



Posts: 7


« Reply #7 on: November 12, 2009, 02:11:46 PM »

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?
IP logged
Salmon Trout
Prodigy



Thanked: 501
Posts: 7,363

Computer: Specs
Experience: Guru
OS: Linux variant

1
« Reply #8 on: November 12, 2009, 03:22:27 PM »

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+,,
IP logged

Geek-9pm
Sage



Thanked: 327
Posts: 8,047

Computer: Specs
Experience: Familiar
OS: Windows XP


Geek After Dark

« Reply #9 on: November 12, 2009, 03:53:08 PM »

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
IP logged
SQLGuy
Topic Starter
Greenhorn



Posts: 7


« Reply #10 on: November 12, 2009, 04:10:25 PM »

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)   :)
IP logged
Geek-9pm
Sage



Thanked: 327
Posts: 8,047

Computer: Specs
Experience: Familiar
OS: Windows XP


Geek After Dark

« Reply #11 on: November 12, 2009, 05:15:04 PM »

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


« Last Edit: November 12, 2009, 06:39:37 PM by Geek-9pm » IP logged
SQLGuy
Topic Starter
Greenhorn



Posts: 7


« Reply #12 on: November 12, 2009, 06:17:38 PM »

Well I wish I could tell you it worked but it did not.

I appreciate the responses!
IP logged
Geek-9pm
Sage



Thanked: 327
Posts: 8,047

Computer: Specs
Experience: Familiar
OS: Windows XP


Geek After Dark

« Reply #13 on: November 12, 2009, 06:40:19 PM »

corrections made above.
IP logged
gh0std0g74
Apprentice



Thanked: 37
Posts: 590


« Reply #14 on: November 12, 2009, 09:52:23 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"

« Last Edit: November 12, 2009, 10:04:46 PM by gh0std0g74 » IP logged

Pages: [1] - (Top) Print 
Home / Microsoft / Microsoft DOS / Need help using the copy command « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.108 seconds with 20 queries.