Computing.Net > Forums > Disk Operating System > copy file to variable folder in bat

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

copy file to variable folder in bat

Reply to Message Icon

Name: nuts
Date: July 6, 2006 at 05:07:10 Pacific
OS: dos
CPU/Ram: 16M
Product: PC
Comment:

Anyone can help me.

l want to copy a file to a number of folder.

for example.
copy c:\file.txt c:\folder001
copy c:\file.txt c:\folder002
.....
.....
copy c:\file.txt c:\folder998
copy c:\file.txt c:\folder999
how l can make it in the batch for define the variable folder?
l try the following but cannot work
copy c:\file.txt c:\folder* OR
copy c:\file.txt c:\folder???

Thanks
Hung



Sponsored Link
Ads by Google

Response Number 1
Name: inverto
Date: July 6, 2006 at 07:39:53 Pacific
Reply:

Which version of DOS ie

MS-DOS Command Prompt:
http://www.computing.net/dos/wwwboard/forum/16200.html

NT Command Prompt:
http://www.computing.net/dos/wwwboard/forum/16197.html


0

Response Number 2
Name: nuts
Date: July 6, 2006 at 09:54:07 Pacific
Reply:

l use msdos command prompt.l can use FOR LOOP in NT command prompt but it cannot work in msdos because it does not support /L switch.

Does any dos tools can help?


0

Response Number 3
Name: dtech10
Date: July 8, 2006 at 08:03:30 Pacific
Reply:

Hi Nuts
Nice Name
This will work for MsDos or the Command Prompt
The three for loops are on one line.
The First copies to folders 000-999
The Second copies to folder 001-999
incase you don't want a folder 000

@echo off
rem Copy File.txt to Folder 000-999
for %%a in (0 1 2 3 4 5 6 7 8 9) do for %%b in (0 1 2 3 4 5 6 7 8 9) do for %%c in

(0 1 2 3 4 5 6 7 8 9) do copy\file.txt\Folder%%a%%b%%c

-----------------------

@echo off
rem Copy File.txt to Folder 001-999
for %%a in (0 1 2 3 4 5 6 7 8 9) do for %%b in (0 1 2 3 4 5 6 7 8 9) do for %%c in

(0 1 2 3 4 5 6 7 8 9) do (
if not "%%a%%b%%c"=="000" copy\file.txt\Folder%%a%%b%%c
)


0

Response Number 4
Name: Mechanix2Go
Date: July 8, 2006 at 09:34:52 Pacific
Reply:

Hi dtech10,

Pretty neat.

One minor point. There ain't no 9 char file/dir names in DOS.


If at first you don't succeed, you're about average.

M2


0

Response Number 5
Name: dtech10
Date: July 8, 2006 at 13:40:42 Pacific
Reply:

Hi Mechanic

Well spotted
Forget about that one.
Guess I too used to WinXP.
Thanks


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: copy file to variable folder in bat

copying files to one directory www.computing.net/answers/dos/copying-files-to-one-directory/12450.html

Copy files only out of sub folders www.computing.net/answers/dos/copy-files-only-out-of-sub-folders/14795.html

COPY file to multiple directories www.computing.net/answers/dos/copy-file-to-multiple-directories/14518.html