Solved

use file name as paramter for bat file to then use xcopy

Posted on 2013-02-04
3
616 Views
Last Modified: 2013-02-08
Is is possible to pass a fle name to a .bat file so that we can then use xcopy. We have many many possible file names that could be supplied with more added all the time.

We had this working with a package we were using in an oracle scheduler. But then some security changed and we keep having issues. Thats a completely different story.

So, one time, a file named JoeFile is generated and needs to be moved to a server \\sfa6\QC_Reports.
Another time, a file generated may be named PatientList and needs to be moved to the \\sfa66\QC_Reports

Any assistance is appreciated.
0
Comment
Question by:jvoconnell
3 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 38851854
Well, basically, it's as simple as
@echo off
setlocal
set /p Filename=Please enter the file name: 
xcopy "%FileName%" "\\sfa6\QC_Reports"

Open in new window

or (for command line input)
@echo off
setlocal
set Filename=%~1 
xcopy "%FileName%" "\\sfa6\QC_Reports"

Open in new window

But you didn't provide any information on how to associate a target share with a file name or any other information that might help making this easier for the user. Any other useful information you can give us?
0
 
LVL 5

Expert Comment

by:FGomez02
ID: 38857894
Also you can créate a txt file with 2 columns, in the first column you can write the name of your file and separated by space in the second column, you can put your path to copy that file.

As for example, our list is called list.txt and has the following columns:

JoeFile \\sfa6\QC_Reports
PatientList \\sfa66\QC_Reports


Now from the command prompt, we can use the following command to parse the full file:

c:\> for /f "tokens=1,2" %f in (list.txt) do xcopy %f %g

And all the lines from the files will be parsed with the command and in one step copy to destination directory.

PS. You'll need to add the file extension if your files have one.
0
 
LVL 1

Author Closing Comment

by:jvoconnell
ID: 38867539
Thank you both for your input.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
The way I use Experts Exchange to assist me in analyzing and diagnosing a problem is I first enter a Verbose Question at Experts Exchange like: Office 2007 will hang when opening and saving files I then launch WordPad (any text editor will do) an…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now