Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi everybody,
I’m trying to make a batch file that copies some files from one place to another. The filenames contain a client number so they differ each time (for example client123.doc or client123.dat).
I’m hoping to make a script that asks for the client number and then it automatically uses that number in all copy commands.So for example:
You run the script.
The script asks for a client number.
You enter “123”.
The script copies all files that contain 123 to a certain folder.
My script so far looks like this:@echo off
Copy "C:\windows\version 1\*123.*" "C:\clients" /y
Copy "C:\windows\version 2\*123.*" "C:\clients" /y
Copy "C:\windows\version 3\*123.*" "C:\clients" /y
Copy "C:\windows\version 4\*123.*" "C:\clients" /y
Copy "C:\Program Files\AA\*123.*" "C:\clients" /yExit
But this doesn’t really work, because you would have to change the client number in each line. How could I automate this?

Modify your script as below
@Echo Off
Set /P Client=Enter Client Number^>
Copy "C:\windows\version 1\*%Client%.*" "C:\clients" /y
Copy "C:\windows\version 2\*%Client%.*" "C:\clients" /y
Copy "C:\windows\version 3\*%Client%.*" "C:\clients" /y
Copy "C:\windows\version 4\*%Client%.*" "C:\clients" /y
Copy "C:\Program Files\AA\*%Client%.*" "C:\clients" /yOf course that is a straightforward enhancement as the input should be checked too, but this would take us far away.

Thank you so much! It works great!
Before your post Ive been searching for an answer myself, but it quickly became too complicated. I knew something simple like this would exist...Unrelated question:
Do you know what a generic path description to your desktop is?
"%UserProfile%\Desktop\" only works with an English OS...

I'm not absuletely sure about what I'm answering to your question related to the desktop's path, but I'm running an italian edition of Windows XP SP2 and what you posted would work for me too.
I suppose the path composed with %UserProfile% variable would be language invariant.

Ive got a dutch version of XP and the desktop is called "bureaublad".
if i use something like
"explorer.exe "%USERPROFILE%\desktop\Data"
to open a folder on my desktop in explorer, it gives an error. Ive got to use the dutch word "bureaublad" in the path.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |