Computing.Net > Forums > Disk Operating System > Batch file to upload data frm flopy

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 to upload data frm flopy

Reply to Message Icon

Name: Russell Rego
Date: August 12, 2003 at 09:10:52 Pacific
OS: Win 95
CPU/Ram: 64 MB
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: August 12, 2003 at 12:52:23 Pacific
Reply:

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 help

ctty nul
%comspec%/F/CDIR/ADH/W/-P A: |FIND ":\" > nul
ctty con

if 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

____________________________________________________


0
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 to upload data frm flopy

create backup cd using batch file www.computing.net/answers/dos/create-backup-cd-using-batch-file/10385.html

Batch file to run on log off! www.computing.net/answers/dos/batch-file-to-run-on-log-off/14751.html

batch file to get subset of dir? www.computing.net/answers/dos/batch-file-to-get-subset-of-dir/15350.html