Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a file in a floppy (name D033ddmm) where dd is day & mm is month in numeric. I need a batch file for the following: (This batch file will copy a file daily from a floppy to a hard disk)
a) Ask user to input file name in format (D033ddmm)
b) Check if file exists in the floppy inserted in drive
c) If exists, copy it to C drive.
d) If not exists, give a message error "File not found in floppy"
e) If floppy is corrupt, give error "Floppy is corrupt, please retry using a new floppy"You can mail me here or at russell_rego@hotmail.com

So, it's just a batch file to copy a file from floppy to C:, right? You mentioned that user will input the file name in format, for instance "D033ddmm". You mean user will input something like "D0331208", not that the batch file should interpret "dd" and "mm" as variables on the filename and calculate such values, right?
The following batch file will do it:
@echo off
if "%1"=="" goto help
if "%1"=="/?" goto help
if "%1"=="-?" goto helpctty nul
%comspec%/F/CDIR/ADH/W/-P A: |FIND ":\" > nul
ctty conif errorlevel=1 goto err_flp
if not exist A:\%1 goto err_file
copy %1 C:
goto end:err_flp
echo Error - floppy is not inserted or is corrupted.
goto end:err_file
echo Error - file not found.
goto end:help
echo.
echo Syntax: %0 filename
echo Usage: Copy file from floppy to C:
goto end:end
echo.Please note that the file is being copied to "C:". That means the file will be copied to the drive C, to whatever directory is the current on that drive. In order change that, for instance specify that the file should be copied to the root, modify the line;
copy %1 C:
to this:
copy %1 C:\
Got it? The input is not made by a prompt, like "type filename:", it is made by passing the filename as a parameter to the batch file. This makes things much simpler, but if you terribly want the user input in "prompt-style", I can make it.
I hadn't had time to test the batch file, please tell me if it worked flawless or not.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br____________________________________________________

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

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