derekstattin
asked on
Adding the date to a file name .CMD funcltion
Shift-1 helped me this code.
I would like to add the date rather than a just adding a 1 to the file name
@echo off
setlocal
set folder=C:\myfolder
for /F "tokens=*" %%G in ('dir "%folder%" /A:-D /B') do (
echo F|xcopy "%folder%\%%G" "%folder%\%%~nG1%%~xG" /C /H /R /Y
)
e.g.
contained in myfolder
test.txt
test2.txt
after running the .cmd
the folder would contain
test.txt
test2.txt
test-10-7-08.txt
test2-10-7-08.txt
thanks for the help
I would like to add the date rather than a just adding a 1 to the file name
@echo off
setlocal
set folder=C:\myfolder
for /F "tokens=*" %%G in ('dir "%folder%" /A:-D /B') do (
echo F|xcopy "%folder%\%%G" "%folder%\%%~nG1%%~xG" /C /H /R /Y
)
e.g.
contained in myfolder
test.txt
test2.txt
after running the .cmd
the folder would contain
test.txt
test2.txt
test-10-7-08.txt
test2-10-7-08.txt
thanks for the help
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sir Bounty,
Thank you for the two examples. The first example works as expected.
The second example create a new folder
When I run the .cmd file, a new folder named test-10 is created in myfolder (where test.txt contained)
Thanks for the help, I am going to post another question related to these results
Thank you for the two examples. The first example works as expected.
The second example create a new folder
When I run the .cmd file, a new folder named test-10 is created in myfolder (where test.txt contained)
Thanks for the help, I am going to post another question related to these results
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ASKER
Is this because of the time zone? I am tijuana/pacific coast US time zone
I could not get any results from si_shamil code, may I need to change something on my end?
thanks