avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday June 15, 2024, 6:32 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Script/batch file that copies two files from a drive(usb) to a location  (Read 59517 times)


  • Member
  • Joined in 2007
  • **
  • Posts: 70
    • View Profile
    • Donate to Member
Re: Script/batch file that copies two files from a drive(usb) to a location
« Reply #25 on: February 03, 2008, 04:58 AM »
Hi Jim,

thanks for the hints. My response is quite likely much too late, but I wasn't around for a while.

I have tried the environment variable %CD% that you mentioned in a batch file like this:


echo %CD%

The output this batch file creates when called from within the directory where it is stored is as expected:


and the output when called from from the root directory is this:


I noticed that the variable is inconsistent in adding a trailing backslash as the the ending character.

CopyMyFiles.cmd is stored in C:\Scripts
At the command prompt, you change directories to F:\Data
From there you type in the command
The %CD% variable will contain the value F:\Data.

I agree with everything you say, but would you not get the same behaviour when omitting the %CD%\ from your suggested CopyMyFiles.cmd?

copy data.exe c:\windows\system32\data
copy pic.jpg C:\Documents and Settings\Administrator\Desktop

I might have misunderstood the original question, but it seems to me that the question was to find a way to refer to the directory where the batch file is located (USB device?), rather than storing the batch on the hard drive.


Schön wär's, wenn's schön wär!