Solved

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

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…

832 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