Computing.Net > Forums > Programming > Batch copy and rename if needed

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch copy and rename if needed

Reply to Message Icon

Name: JulianDavidson
Date: September 27, 2006 at 16:06:13 Pacific
OS: W2K
CPU/Ram: Celeron 1.2GHz 512MB
Comment:

Hi
Pretty new to batch files, and brand new to this forum... hoping someone can help me. I need a batch file that will move all files in one directory to another directory. If the filename already exists in the destination directory, all it needs to do is append the date and time that the file it's handling was created to the filename.

Hope someone can help ..?

Cheers
Julian.



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: September 30, 2006 at 17:34:02 Pacific
Reply:

You can't append the date and time the original file was created. You can however, append the current date and time using the %date% and %time% environment variables.

I don't have time to write you a script,but, the basics would be a FOR loop that using something like for %%i in (*) do goto mover. Then have a label named :mover that uses the if exist command to check the dirrectory to see if the filename exist. If it doesn't it moves the file, else, rename the file to filename%date%%time% then move.

I hope that Pseudo Code helps.

"Computer security." — Oxymoron


0

Response Number 2
Name: dtech10
Date: October 1, 2006 at 08:20:15 Pacific
Reply:

Hi Julian
When renaming do you want to keep the extension ie File.txt to "File Date Time.txt"
or "File.txt Date Time"
I take it this is only done once.
I'm english and using WinXp
The command "echo %Date% on your system
would be somthing like "Sun 10/01/2006"
I assuming, is the correct.



0

Response Number 3
Name: JulianDavidson
Date: October 1, 2006 at 19:21:28 Pacific
Reply:

Thanks for the replies. I got the need for this sorted another way.

If you can help with a windows shortcut question, I'm starting another topic:
http://www.computing.net/windows200...

Cheers
julian.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


VB and Wget Easter Eggs in Software



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch copy and rename if needed

Batch file copy and Rename www.computing.net/answers/programming/batch-file-copy-and-rename/18689.html

BATCH to copy and rename files www.computing.net/answers/programming/batch-to-copy-and-rename-files/15221.html

Copy and Rename Batch File www.computing.net/answers/programming/copy-and-rename-batch-file/15297.html