Jump to content

Recommended Posts

Posted

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.


Posted (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 by crahak
Posted (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%"

pause

copy "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"

pause

rename "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%.txt

pause

exit

Edited by donvier
Posted

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?

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...