Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello. I would like to make a batch file that will copy files from my pendrive (let's say, z:) to my PC's hard drive.
I know how to use the XCOPY command, but the twist here is that I want to rename the files each time their are copied, with the current date and, if possible, hour. Example:
Original file: document1.doc
Copied file: 2007-08-05document1.docOr something like that. Is this possible? If yes, how?
Thanks for any help.

[1] The example file names are no-go in DOS.
[2] You cannpt mass renamr with xcopy.
[3] You may want to check out the programming forum.
=====================================
If at first you don't succeed, you're about average.M2

Perhaps something like:
(it should work on 2000/XP only, not in
Win98)========= COPYFILE.BAT ========
:: Meant to be called only form
:: COPYPD.BAT, this doesn't perform
:: any parameter checking
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
IF EXIST %4%2%1\NUL GOTO END
if NOT EXIST %3%2NUL md %3%2
copy %4%2%1 %3%2%date%%1
if ERRORLEVEL 1 PAUSE:END
ENDLOCAL
============= EOF ======================= COPYPD.BAT =========
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SET PD=Z:
IF "%1"=="/?" GOTO HELP
IF "%1"=="" GOTO HELP
IF NOT EXISTS %1\NUL GOTO ERROR
for /r %PD%\ %i in (*.*) do call COPYFILE.BAT "%~nxi" "%~pi" "%1" %PD%
GOTO END:ERROR
ECHO The destination %1 doesn't exist.
GOTO END:HELP
ECHO Copies the contents of the pendrive in
ECHO Z: to the specified destination.
ECHO.
ECHO Syntax:
ECHO COPYPD dir
ECHO Parameters:
ECHO dir = Directory where the files will
ECHO be copied to.
ECHO.:END
ENDLOCAL
============= EOF =============

![]() |
![]() |
![]() |

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