Sign in with
Sign up | Sign in
Your question
Solved

cmd script for moving rar files to another directory.

Last response: in Windows XP
Share
September 19, 2013 7:37:09 AM

i have ERP system running on server 2003. it create daily backups on desktop. (.RAR files). so i want to move those rar files which is older than 1 day to my E drive.
please help.
September 19, 2013 7:40:19 AM

I am not quite sure about that but i think that you can browse with cmd only in the hard drive where win os is installed
m
0
l
September 19, 2013 7:47:47 AM

tonyzet said:
I am not quite sure about that but i think that you can browse with cmd only in the hard drive where win os is installed


but can you help me with .bat file..?
m
0
l
Related resources
September 19, 2013 7:52:34 AM

Sorry, but it would be better to ask a more advanced member of the forum or an computer engineer for help
m
0
l

Best solution

September 19, 2013 7:55:20 AM

Use Robocopy: http://ss64.com/nt/robocopy.html ROBOCOPY Source_folder Destination_folder [files_to_copy] [options]

sooo ROBOCOPY c:\folder e:\folder *.rar /MINAGE:1

save it as a .bat file and schedule it to run once a day, you can add the /MOV option if you want to delete the files from the source directory.
Share
September 19, 2013 8:14:47 AM

chugot9218 said:
Use Robocopy: http://ss64.com/nt/robocopy.html ROBOCOPY Source_folder Destination_folder [files_to_copy] [options]

sooo ROBOCOPY c:\folder e:\folder *.rar /MINAGE:1

save it as a .bat file and schedule it to run once a day, you can add the /MOV option if you want to delete the files from the source directory.


thank you so much... i"ll check this and get back.
m
0
l
September 19, 2013 8:24:05 AM

CMD line commands are extremely powerful and you can do some pretty neat things with it, it's a good thing to learn, look at all we can do with 1 line of code.
m
0
l
September 19, 2013 9:01:08 AM

chugot9218 said:
CMD line commands are extremely powerful and you can do some pretty neat things with it, it's a good thing to learn, look at all we can do with 1 line of code.


is there are any good site to learn those things
m
0
l
September 19, 2013 9:06:24 AM

Yup the one I posted previously is the best reference I have found, w3schools.com might have something too. Here is the main CMD index at my first post: http://ss64.com/nt/
m
0
l
September 19, 2013 9:18:32 AM

chugot9218 said:
Yup the one I posted previously is the best reference I have found, w3schools.com might have something too. Here is the main CMD index at my first post: http://ss64.com/nt/


thanks..
m
0
l
September 20, 2013 8:22:46 AM

can't use robocopy cuz i'm using server 2003. so i created xcopy command below.

xcopy c:\documents and settings\asministrator\desktop\ *.rar E:\daily backup\

but it won't work... it says invalid parameter...
m
0
l
September 24, 2013 10:36:38 AM

Sorry was out of the area this weekend, is that the actual line you used? If so, you have a space after the last \ in your source. Otherwise, it may be too old an OS to support wild cards. If you still need help post back.
m
0
l
September 24, 2013 1:18:30 PM

chugot9218 said:
Sorry was out of the area this weekend, is that the actual line you used? If so, you have a space after the last \ in your source. Otherwise, it may be too old an OS to support wild cards. If you still need help post back.


really need help... i will trying removing the space, and then i get back to you...
m
0
l
September 24, 2013 1:44:10 PM

Ooops, also you need to contain it in "'s, this should be the proper one (I assume you mis-typed the administrator portion).

xcopy "c:\documents and settings\administrator\desktop\*.rar" "E:\daily backup\"

That should do it for you.
m
0
l
September 25, 2013 12:13:17 PM

chugot9218 said:
Ooops, also you need to contain it in "'s, this should be the proper one (I assume you mis-typed the administrator portion).

xcopy "c:\documents and settings\administrator\desktop\*.rar" "E:\daily backup\"

That should do it for you.


Its working.. thank you so much... can you please tell me how to add log report for this.. please...
m
0
l
September 26, 2013 10:27:40 AM

I am learning new stuff myself helping you. Try this:

ECHO.| DATE >> "E:\daily backup\backuplog.txt"
xcopy "c:\documents and settings\administrator\desktop\*.rar" "E:\daily backup\" >> "E:\daily backup\backuplog.txt"

This may give you strange results though if you are prompted by XCopy, for example, I did not specify that xcopy should automatically overwrite a file, so when it prompted me with Overwrite C:\ROBOCOPYtest\test.txt (Yes/No/All)? that text was automatically written to the log file instead of displayed in the command console which can be somewhat confusing.

If you will never have to worry about overwrites, then you are good to go with these two lines. Otherwise you could append the option to XCOPY to overwrite without prompt if that's what you desire, in which case it would look like this:

ECHO.| DATE >> "E:\daily backup\backuplog.txt"
xcopy "c:\documents and settings\administrator\desktop\*.rar" "E:\daily backup\" >> "E:\daily backup\backuplog.txt" /Y

Careful that you don't run into access issues or the .bat can go into an infinite loop, in Win7 I had to run it as administrator.
m
0
l
September 27, 2013 1:43:48 AM

chugot9218 said:
I am learning new stuff myself helping you. Try this:

ECHO.| DATE >> "E:\daily backup\backuplog.txt"
xcopy "c:\documents and settings\administrator\desktop\*.rar" "E:\daily backup\" >> "E:\daily backup\backuplog.txt"

This may give you strange results though if you are prompted by XCopy, for example, I did not specify that xcopy should automatically overwrite a file, so when it prompted me with Overwrite C:\ROBOCOPYtest\test.txt (Yes/No/All)? that text was automatically written to the log file instead of displayed in the command console which can be somewhat confusing.

If you will never have to worry about overwrites, then you are good to go with these two lines. Otherwise you could append the option to XCOPY to overwrite without prompt if that's what you desire, in which case it would look like this:

ECHO.| DATE >> "E:\daily backup\backuplog.txt"
xcopy "c:\documents and settings\administrator\desktop\*.rar" "E:\daily backup\" >> "E:\daily backup\backuplog.txt" /Y

Careful that you don't run into access issues or the .bat can go into an infinite loop, in Win7 I had to run it as administrator.


i will try this..but before that i have run in to problem.. when the script run it always ask to overright ... i have to type "N" always. otherwise it won't copy. is there any way to write this in script. I want it to not overwright exsisting file when copying... thanks...
m
0
l
!