Computing.Net > Forums > Disk Operating System > BAtch file: how to make this?

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 file: how to make this?

Reply to Message Icon

Name: Over
Date: August 5, 2007 at 05:47:04 Pacific
OS: Vista
CPU/Ram: E6600 4GB
Product: intel
Comment:

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.doc

Or something like that. Is this possible? If yes, how?

Thanks for any help.




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 5, 2007 at 06:14:42 Pacific
Reply:

[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



0

Response Number 2
Name: alexanrs
Date: August 8, 2007 at 14:53:07 Pacific
Reply:

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 =============


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: BAtch file: how to make this?

Dos Commands in a batch file www.computing.net/answers/dos/dos-commands-in-a-batch-file/1258.html

How to make boot-up disk? www.computing.net/answers/dos/how-to-make-bootup-disk-/451.html

Modifying registry key thru batch file www.computing.net/answers/dos/modifying-registry-key-thru-batch-file/9103.html