Append Date

Microsoft Windows xp professional w/serv...
December 2, 2009 at 09:00:46
Specs: Windows XP
Hello,

I need some help I need simple batch file that copies files from Folder A to B .. while copying it appends system date...

So all files with extension TXT should be Copied from A to B with Appended date ...

I got some batch files that can do it but only to one files ...

Thank You


See More: Append Date

Report •


#1
December 2, 2009 at 10:07:33
@echo off

Set Day=%Date:~-7,2%
Set Month=%Date:~-10,2%
Set Year=%Date:~-2,2%

For /F "tokens=1,2 delims=." %%A in ('DIR %1*.txt /b') do (
copy "%1%%A.%%B" "%2%%A%Month%-%Day%-%Year%.%%B"
)

The systax would be, assuming you used mycopy.bat for your file....

mycopy c:\mydir\ c:\mynewdir\


Report •

#2
December 2, 2009 at 10:38:14
Thank Thank you very much ... Works like a charm

just one small question how I can make this to execute as one file ... instead of cmd>>mycopy c:\mydir\ c:\mynewdir\ I rather double click on batch file ..

Is there a simple way to do it ?


Report •

#3
December 2, 2009 at 12:23:02
mycopy c:\mydir\ c:\mynewdir\
@echo off

Set Day=%Date:~-7,2%
Set Month=%Date:~-10,2%
Set Year=%Date:~-2,2%

For /F "tokens=1,2 delims=." %%A in ('DIR %1*.txt /b') do (
copy "%1%%A.%%B" "%2%%A%Month%-%Day%-%Year%.%%B"
)

I tried something like this inside bat file but no luck :/


Report •

Related Solutions

#4
December 2, 2009 at 13:46:42
Well to help you further you will need to tell me a little bit about what you are doing and what problem you are trying to solve. I tried the code inside of a batch file and it worked for me. Granted I setup a Shortcut that ran the following...

"C:\Users\myname\Desktop\New Folder\test4.bat" c:\ c:\test\

in the taget of my shortcut. I called my batch file test4.bat and made a test folder on my c: then ran it and it worked. This program will only work if the destination folder exists. If you want to make the destination folder then use the following code...

@echo off

Set Day=%Date:~-7,2%
Set Month=%Date:~-10,2%
Set Year=%Date:~-2,2%

If exist %2 goto End
MD %2

:End
For /F "tokens=1,2 delims=." %%A in ('DIR %1*.txt /b') do (
copy "%1%%A.%%B" "%2%%A%Month%-%Day%-%Year%.%%B")

Got to remember every thing we provide is sample code typed off the tops of our heads. It is to help you get unstuck and assumes you know about batch file programming.

If you want to learn batch file scripting please go here...

http://www.robvanderwoude.com/batch...


Report •

#5
December 2, 2009 at 14:16:24
Hello Thank You for great answer ...
I'm calling that batch file from external application and I can't specify syntax source ... and destination folder ...

So I'm trying to include source and destination folder in the batch file ...


Report •

#6
December 2, 2009 at 14:39:55
What is the other application that you are trying to call the batch file from? If it is another batch file can you post the script?

Report •

#7
December 2, 2009 at 14:49:07
its a just small GUI ... to run them I can't pass syntax there ...

Report •

#8
December 2, 2009 at 14:55:37
Is the GUI downloadable freeware or did you write it yourself? I can't help you unless I have the GUI you are using.

Report •


Ask Question