Copy a file to unknown directory name

Dec 18, 2008
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.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
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.
>
>
>
>
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
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*]
 
May 20, 2008
603
0
Sammamish, WA
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.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
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
Thread starter Title Forum Replies Date
R How to? TCC 16.03: copy a file to the clipboard? Support 10
A How to? Instruct COPY to delete file if only partially copied (via FTP) Support 8
A Discrepancy in handling of "can't copy or move file to itself" Support 4
C Copy (sys) error Support 3
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
vefatica Copy/Paste anomaly Support 4
D Documentation Typo in COPY help Support 0
samintz COPY fails to copy from \\wsl$ Support 20
D Differences between TCC and CMD with COPY /b Support 4
fpefpe copy /u and timestamps Support 4
M Strange error messages from TCC in FTP copy Support 7
G TCMD crash when copy Support 3
Alpengreis How to? Copy DIRs with attributes ... Support 4
E Text copy bug Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
fpefpe copy/cat Support 7
K copy /w slow relative to robocopy /mir Support 0
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
K "copy /z /w" command not deleting read-only files in destination Support 10
K copy changing destination current directory Support 1
D Keystroke to copy previous argument Support 3
A How to? Copy+Paste in TCMD tabs with Ctrl-Shift-Ins? Support 5
RChrismon How to? Copy TCMD.INI to New Version Support 7
R How to? Append files in multiple subfolders using copy? Support 8
Dick Johnson COPY /u (?) Support 9
fpefpe Documentation copy /u Support 7
R How to? copy /q ABC.txt + DEF.txt is appending hex 1A Support 8
D copy /g only shows transfer rate Support 1
J Error "Contents lost before copy" Support 3
B Can copy command concatenate multiple mp3 files Support 2
rps Documentation "Copy+Paste+run" question Support 2
kb6ojs Make /G parameter persistent in COPY/MOVE command? Support 4
fpefpe How to? copy / exclude Support 2
fpefpe robocopy -- copy /w Support 8
C copy /w /p prompts for deletion, but ... Support 3
D Fixed Copy Support 1
fpefpe Documentation copy/move using /c or /u Support 2
samintz WAD Copy/append adds a character Support 3
P Simple RegEx copy Support 9
fromano Fixed COPY ... TO ... crashing Support 3
Alpengreis How to? Copy & Paste without linebreak within TCMD Support 13
D COPY returns ERRORLEVEL 2 Support 5
mdwyer TCC 13 COPY: specified network name is no longer available. Support 5
CWBillow Copy a tree Support 17
J junction copy/move handling Support 6
vefatica Fixed COPY /S ftp://... Support 1
C WAD copy /u ftp local with Timeout? Support 5
D How to? Unregister a copy of Take command Support 1
vefatica FTP copy interrupted Support 2
C How to? COPY ftp folder query Support 7

Similar threads