donvier Posted July 8, 2008 Posted July 8, 2008 I am trying to capture/archive multiple versions of a file with the same name without having the destination overwritten everytime. I was thinking of doing something that checks to see if the file exists and if it does add a numerical number or something at the end. i tried to add $date$ to the file name to keep it unique but the date format is mm/dd/yyyy which windows doesnt like because of the / in the file name. how else could i do this in order to make it completely automated. This will be on an XP Pro or 2003 box and i am stuck with the programs on the box, cannot install 3rd party products. I can get the file to copy and all that good stuff it just keeps overwritting the destination file. i cannot rename the file prior to the move because another program that will run shortly after depends on it. i want to get a snapshot of this file prior to the other program kicking off. i looked at xcopy but all i see is the ability to have it prompt to overwrite. any help will be appreciated. thanks in advance.
CoffeeFiend Posted July 8, 2008 Posted July 8, 2008 (edited) You could use any scripting language to solve this (very easily).Personally, I recommend naming using the ISO date format i.e. YYYY-MM-DD, which is always shown in the perfect sort order.Edit: the script isn't a 3rd party app per se, it runs on the windows scripting host. Edited July 8, 2008 by crahak
jaclaz Posted July 8, 2008 Posted July 8, 2008 Looky here:http://www.msfn.org/board/Rename-File-With...-Fi-t47812.htmljaclaz
donvier Posted July 8, 2008 Author Posted July 8, 2008 (edited) Thanks for the help guys! I do believe i have something that will do what i need now.without the pauses of course. if you cant tell this is pretty much my first batch file ever so any tips other than "you're an id***" are more than welcome lol.cd\mkdir "C:\Documents and Settings\user\Desktop\batchcopydestinationtest\%Date:~-10,2%_%Date:~-7,2%_%Date:~-4,4%"pausecopy "C:\Documents and Settings\user\Desktop\batchcopytest\cu0169" "C:\Documents and Settings\user\Desktop\batchcopydestinationtest\%Date:~-10,2%_%Date:~-7,2%_%Date:~-4,4%\cu0169"pauserename "C:\Documents and Settings\user\Desktop\batchcopydestinationtest\%Date:~-10,2%_%Date:~-7,2%_%Date:~-4,4%\cu0169" %Date:~-10,2%_%Date:~-7,2%_%Date:~-4,4%_%time:~-2,8%.txtpauseexit Edited July 8, 2008 by donvier
Yzöwl Posted July 8, 2008 Posted July 8, 2008 The example you've provided simply does a copy and rename on a directory.I think that you may need a little more help, can you let us know specifically what you have and what you are trying to do. Your post suggests that you have files in many places which you are trying to place in a single location. How are you locating these files? Are they in specific known locations? Do they have specific/known names, extensions or modification/creation times? Is there a known number of them? How important is the final naming schedule?
donvier Posted July 9, 2008 Author Posted July 9, 2008 i had one file in one location and right now it is going to run as a scheduled task grab a copy of the file and put it in a month/day directory named date time.txt this will work for what i was looking for. really i just wanted to grab a copy of the file, move it to another directory and make it so the next time the file runs it doesnt overwrite the last one. i appreciate the help though. one thing i have no clue about is what the #,# is after the date and time, that part i got from someone else.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now