Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Boneheaded question of the day

Status
Not open for further replies.

backlund

Technical User
Nov 30, 2004
50
US
For the life of me, I must be losing it because I can't figure this out, or find anything on it. I'm sure it's easy, but I'm asking for help now!

I have a script that copies my documents to a folder every night on a second hard drive, for backup reasons.

I want to set the script up so that once a month it renames the folder. This will give me a clean backup of the my documents folder and not include all the junk I don't need. When the old folder is renamed, I will still have access to old stuff I deleted in case I need it.

Anyway, I can't figure out how to rename the folder through command line! I'm sure I'm just doing something wrong.

If anyone knows how to rename a folder through command line, I would appreciate the help.

Otherwise, if there is an easy command that would allow syncing between two folders, that would work as well.

I don't want to delete the backup my documents folder every night, because it has about 4 gig of pictures in it that I don't want to wait for to copy every night. Currently the backup script does an initial copy, and then only copies files that have a changed "Modified" date on them, or any new files that are added.

Thanks!
 
Renames a file or files.

RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.

Note that you cannot specify a new drive or path for your destination file.

the other method is using the move command.

move C:\myfile.txt d:\hisfile.txt

this will create a file named hisfile.txt in drive D: with the contents of myfile.txt from the C: drive. and will delete myfile.txt from the c: drive.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I tried the rename command and it seems to be reserved only for files, unless I'm doing something wrong. The MOVE command, is the key, now that I think about it! Thanks for the refresher!
 
Rename works with folders also. you can't rename folders that are not located excatly where the command was issued.

Code:
C:\>rename C:\files\documents C:\files\olddocuments

will not work, however
Code:
C:\files\>rename documents olddocuments

will work fine.

Also long names will cause erros, for example:

My Documents , would be referred to at command line level as MyDocu~1
This is because most command line commands retain the 8.3 name convention. that is 8 characters for the name a 3 for extension.

Also folders that have names that contain "." will also cause trouble.

To find out what the 8.3 name of a folder would be you can use the Dir commans with the /x modifier.

DIR /X.

Hope this helps.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
You can always user
Code:
RENAME "My Douments" "My Old Documents"

Hope this helps.

Thanx!

Dave Shaw
History admires the wise, but elevates the brave. - Edmund Morris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top