Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article covers how to install the Microsoft Windows Operating System (OS). What is covered in this article:  > Different Versions and Editions of the Windows OS  > Upgrading versus Fresh Installation of the OS           - Steps to take pr…
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…
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…

746 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

13 Experts available now in Live!

Get 1:1 Help Now