?
Solved

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

Posted on 2013-02-04
3
Medium Priority
?
622 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 1500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
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…

764 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