Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Copy a file to unknown directory name

Dec
4
0
This might be simple.

I need to copy a file to a directory name that will be changing monthly.

I _know_ the directory name will be the only directory that starts with a "2" so Dir 2* will always return my directory name (for example, 20090430)

How can I copy a file to that directory name?

One way thought I had was to store the directory name as a variable (actually store the directory name in a file and then create a variable from the one line in that file) and then copy the file to that variable name.

Is there any easier way?

Thanks.
 
Well, if it's as simple as copying a single file, just use <TAB>
completion to fill out the directory name.

copy myfile 2<TAB>

etc.

-Scott

glennw <> wrote on 06/08/2009 11:21:52 AM:


> This might be simple.
>
> I need to copy a file to a directory name that will be changing monthly.
>
> I _know_ the directory name will be the only directory that starts
> with a "2" so Dir 2* will always return my directory name (for
> example, 20090430)
>
> How can I copy a file to that directory name?
>
> One way thought I had was to store the directory name as a variable
> (actually store the directory name in a file and then create a
> variable from the one line in that file) and then copy the file to
> that variable name.
>
> Is there any easier way?
>
> Thanks.
>
>
>
>
 
This might be simple.

I need to copy a file to a directory name that will be changing monthly.

I _know_ the directory name will be the only directory that starts with a "2" so Dir 2* will always return my directory name (for example, 20090430)

How can I copy a file to that directory name?

One way thought I had was to store the directory name as a variable (actually store the directory name in a file and then create a variable from the one line in that file) and then copy the file to that variable name.

Is there any easier way?

You can skip the intermediate file and stash the name directly in a variable using @EXECSTR:

Code:
set dirname=%@execstr[dir /ad /f 2*]
 
You could also use this in a batch file

copy myfile %@expand[2*,d]


On Mon, Jun 8, 2009 at 8:21 AM, glennw<> wrote:

> This might be simple.
>
> I need to copy a file to a directory name that will be changing monthly.
>
> I _know_ the directory name will be the only directory that starts with a "2" so Dir 2* will always return my directory name (for example, 20090430)
>
> How can I copy a file to that directory name?
>
> One way thought I had was to store the directory name as a variable (actually store the directory name in a file and then create a variable from the one line in that file) and then copy the file to that variable name.
>
> Is there any easier way?
>
> Thanks.
>
>
>
>
>



--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
 
glennw wrote:
| This might be simple.
|
| I need to copy a file to a directory name that will be changing
| monthly.
|
| I _know_ the directory name will be the only directory that starts
| with a "2" so Dir 2* will always return my directory name (for
| example, 20090430)
|
| How can I copy a file to that directory name?
| ...
|
| Is there any easier way?



samintz wrote:
| Well, if it's as simple as copying a single file, just use <TAB>
| completion to fill out the directory name.
|
| copy myfile 2<TAB>
|
| etc.

If instead of interactively, you need to it in a batch file, you could do it
as:

copy myfile %@expand[2*,D]
--
HTH, Steve
 

Similar threads

Replies
7
Views
2K
Back
Top