![]()
[<<]Message[>>] [<<]Author [<<]Subject[>>] [<<]Thread[>>]
Number : 9120 Date : 2004-11-02 Author : Peter Innes Subject : Re: Copy to new Filename or Directory Size(KB) : 3
Thanks very much for your suggestions. I will take up one of these. Peter John Zeman wrote: --- In xxcopy@yahoogroups.com, Peter Innes wrote: > Thanks very much for your swift reply. xxcopy seemed to be so powerful that it is a great surprise to me that it doesn't have such an obvious feature that even DOS xcopy had! > > I'm trying to copy a file to a date-stamped filename. Over time a series of date-stamped copies of the file from at different times will build up. It's part of a backup strategy. > > I may have to copy the file somewhere then rename. > > Thanks, > Peter As Garry mentioned, in general xxcopy deliberately does not allow files to be copied and renamed even though xcopy does. To learn why, you can read technical bulletin #2 at: http://www.xxcopy.com/xxcopy02.htm I don't know if this would be satisfactory to you, but an easy way to resolve the "name by date" problem could be to leave the file names as they are, but copy them to a date stamped directory in the destination which xxcopy will do. For example: xxcopy "C:\SRC\" "D:\DST\/$YYYY-MM-DD$\" The above automatically create a destination directory named D:\DST\2004-11-02\ (which is today's date) and then copies the source files to it. My example is just an example, there are many other possible ways to use the current (and even not current) date/time in a destination directory name. For more information on that you can read technical bulletin #24 at: http://www.xxcopy.com/xxcopy24.htm The advantage of copying to a date stamped directory as opposed to renaming the files according to the current date is at least twofold. One, the possibility of name clashes when the files are copied is almost virtually eliminated. Two, the files can be recognized for what they are because they retain the original name. However if you really wish to rename the files according to the current date, one way would be to xxcopy the files to the destination as you normally would, then run a script to rename them by date. For example, the below would append the current date to each file name (works with NT, 2000, or XP systems only) @echo off :: SET DIRECTORY WHOSE FILES WILL BE RENAMED BY DATE pushd D:\DST\FOLDER :: Get current date. Note this is dependent :: upon the date format in the machine being :: DDD MM/DD/YYYY :: if not, adjust tokens in next line accordingly. for /f "tokens=2-4 delims=/ " %%f in ('date /t') do ( set MM=%%f& set DD=%%g& set YYYY=%%h ) set TODAY= %YYYY%-%MM%-%DD% for /f "delims=*" %%a in ('dir "*.*" /b /s /a:-d') do ( ECHO ren "%%~dpnxa" "%%~na%TODAY%%%~xa" ) popd Note 1: The above will not actually rename anything unless you remove the ECHO in the line: ECHO ren "%%~dpnxa" "%%~na%Z%%%~xa" Note 2: To not rename files in the subdirectories, remove the /s between /b and /a:-d Note 3: The above will not rename hidden or system files (you'll see "The system cannot find the file specified" errors if there are any hidden or system files). John Yahoo! Groups SponsorADVERTISEMENT --------------------------------- Yahoo! Groups Links To visit your group on the web, go to: http://groups.yahoo.com/group/xxcopy/ To unsubscribe from this group, send an email to: xxcopy-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. --------------------------------- ALL-NEW Yahoo! Messenger - all new features - even more fun! [Non-text portions of this message have been removed]
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.