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
Solved

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

Posted on 2013-02-04
3
619 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 84

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

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

Suggested Solutions

Title # Comments Views Activity
GPO not applied 4 79
Office 2016 Error 4 69
question about windows batch/script 3 65
how to run this deletion request 4 30
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

856 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