Computer Hope

Microsoft => Microsoft DOS => Topic started by: ehsan_08 on August 20, 2008, 02:07:37 PM

Title: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 20, 2008, 02:07:37 PM
lets say i have about 10 folders in C:\files\
and i have 3 files that needs to be copied to every of those 10 folders, any idea how?
and let me know if i can make a exception for a folder to not be cpoied ;D


maybe something like:
Code: [Select]
set /p dir= DIR
copy "1.txt+2.txt+3.txt "%dir%

??????????????????


thanks
Title: Re: copy 3 files to every directory in a certiain folder
Post by: fireballs on August 20, 2008, 05:06:36 PM
the code you've got should work just without the quotation marks...
also unless you want to change the directory you're copying into then there's no need for the /p argument.

Code: [Select]
set dir= DIR
copy 1.txt+2.txt+3.txt %dir%

keep us informed

FB
Title: Re: copy 3 files to every directory in a certiain folder
Post by: Sidewinder on August 20, 2008, 07:01:30 PM
Quote
Lets say i have about 10 folders in C:\files\
and i have 3 files that needs to be copied to every of those 10 folders, any idea how?

Code: [Select]
@echo off
set folder=c:\files
for /f "tokens=* delims=" %%v in ('dir /a:d /b %folder%') do (
copy 1.txt %folder%\%%v
copy 2.txt %folder%\%%v
copy 3.txt %folder%\%%v
)
   

Using code like copy "1.txt+2.txt+3.txt "%dir% will append the text files into a single file labeled 1.txt

 8)
Title: Re: copy 3 files to every directory in a certiain folder
Post by: fireballs on August 20, 2008, 07:05:22 PM
I'm such a tard i was so lost in using copy i forgot what the original problem was  >:( grrrr

FB
Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 20, 2008, 08:53:18 PM
no luck, i got this:
(http://i35.tinypic.com/qrddhj.jpg)

 :-\ :-[ :-[ :-[ :-[
Title: Re: copy 3 files to every directory in a certiain folder
Post by: Dias de verano on August 21, 2008, 12:19:35 AM
I expect the target folder name needs quote marks around it, judging by that screen shot.

Code: [Select]
copy 1.txt "%folder%\%%v"
... etc







Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 12:57:09 AM
thanks, that worked!!

now to improve it a bit more, if u will help ;D
anyway to make it ask u for the location, so i don'y have to edit the bat everytime, instead the bat asks me for the dir

i tried this, doesn't work:
Code: [Select]
@echo off
set /p location= Type in the directory please.
set folder= %location%
for /f "tokens=* delims=" %%v in ('dir /a:d /b %folder%') do (

copy 1.txt "%folder%\%%v"
copy 2.txt "%folder%\%%v"
copy 3.txt "%folder%\%%v"
)



pause

EDIT:btw,
about this part:

   copy 1.txt "%folder%\%%v"
   copy 2.txt "%folder%\%%v"
   copy 3.txt "%folder%\%%v"

one file's name has an space in the name of it, so it says not found, but when i replaced with a _
it worked
anyway to not put _?
Title: Re: copy 3 files to every directory in a certiain folder
Post by: Dias de verano on August 21, 2008, 01:51:35 AM
That screen shot is much too big. Making scroll bar appear.

The file names are 1.txt 2.txt and 3.txt. I do not see any spaces.

Do not understand about _ An underscore _ is not a space.

When you say "doesn't work", please give more details.

Code: [Select]
@echo off
set /p location= Type in the directory please.
set folder= %location%

Remove the spaces after the = signs.






Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 02:42:23 AM
i see, it worked ;)
ty
sorry for that huge pic

and btw, the names of those txt files, those were the samples, tests out

wut i mean, i have 2 files, lets say "Dos is cool.txt"
it won't find it, since theirs space in the filesname ???
Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 01:23:37 PM
PLEASE HELP!!

its almost done!!!
im having one problem, when u put a DIR to go on, if the dir has space in it, it won;t work?

for ex: C:\files to backup\
won't work cuz of the space in em

but this:
C:\filestobackup\
works?

any idea??
Title: Re: copy 3 files to every directory in a certiain folder
Post by: fireballs on August 21, 2008, 01:27:31 PM
put it in quotes...

Code: [Select]
for ex: "C:\files to backup\"
FB
Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 02:08:32 PM
Quote
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.


heres the code:
Code: [Select]
set /p location=Type in the directory please (ex. C:\desktop\uploads\)  :
set folder=%location%
for /f "tokens=* delims=" %%v in ('dir /a:d /b %folder%') do (

copy xxxxxx "%folder%\%%v"
copy xxxxxx "%folder%\%%v"
copy xxxxxx "%folder%\%%v"
)




echo Finished!
echo.
pause
Title: Re: copy 3 files to every directory in a certiain folder
Post by: Dias de verano on August 21, 2008, 02:17:26 PM
works fine on my system.

What does xxxxxx represent? If it represents filenames with spaces, then you should know by now what to do.

Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 02:24:48 PM
im sorry
the xxxxx are for some files, if i put the real name, might be a spam in here :-[

im having trouble with the folder name, when it asks for a folder,
the folder:
C:\files backup\
won't work, and when i put ""

here, the real file:

try it on a folder that has spaces
Title: Re: copy 3 files to every directory in a certiain folder
Post by: Dias de verano on August 21, 2008, 02:31:36 PM
I am having great difficulty understanding what you are trying to do.

Why have you posted a link to an exe file? I though this was a batch file forum.

This is turning into one of "those" threads.

Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 02:57:25 PM
i compiled it to a exe file, in order to keep the 3 files also

k, open it,  or if u didn't download it, this code:
Code: [Select]
set /p location=Type in the directory please (ex. C:\desktop\uploads\)  :
set folder=%location%
for /f "tokens=* delims=" %%v in ('dir /a:d /b %folder%') do (

copy 1.txt "%folder%\%%v"
copy 2.txt "%folder%\%%v"
copy 3.txt "%folder%\%%v"
)




echo Finished!
echo.
pause

where it asks for a location, i tryed C:\files backup\
it doesn't work cuz of that space in the name
then i tried C:\files_backup\

i changed the folders name, and took out the space, and it worked

how can set it to a location with some spaces in the location for ex: C:\files backup\
Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 03:18:44 PM
so any idea? ???
Title: Re: copy 3 files to every directory in a certiain folder
Post by: fireballs on August 21, 2008, 03:22:17 PM
Code: [Select]
set /p folder=Type in the directory please (ex. C:\desktop\uploads\)
for /f "tokens=* delims=" %%v in ('dir /a:d /b "%folder%"') do (

copy 1.txt "%folder%\%%v"
copy 2.txt "%folder%\%%v"
copy 3.txt "%folder%\%%v"
)

echo Finished!
echo.
pause

does it work now?

FB
Title: Re: copy 3 files to every directory in a certiain folder
Post by: Dias de verano on August 21, 2008, 03:44:05 PM
Do NOT post exe files. You should remove it straight away.

Why will you not say the names of the 3 files?

Are you trying to do something illegal?



Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 05:45:45 PM
Code: [Select]
set /p folder=Type in the directory please (ex. C:\desktop\uploads\)
for /f "tokens=* delims=" %%v in ('dir /a:d /b "%folder%"') do (

copy 1.txt "%folder%\%%v"
copy 2.txt "%folder%\%%v"
copy 3.txt "%folder%\%%v"
)

echo Finished!
echo.
pause

does it work now?

FB

YES!!
thank u

Do NOT post exe files. You should remove it straight away.

Why will you not say the names of the 3 files?

Are you trying to do something illegal?




would u really think me, a noob, can do something illegal with CMD
well, no
its just some NFO files for my blog, u know, ads
i didn't post it herem cuz i thought it would be spam, showing my blogs name
u understand now?  ;)

thank you both  ;D
Title: Re: copy 3 files to every directory in a certiain folder
Post by: Zylstra on August 21, 2008, 06:44:50 PM

Do NOT post exe files. You should remove it straight away.

Why will you not say the names of the 3 files?

Are you trying to do something illegal?
would u really think me, a noob, can do something illegal with CMD
well, no
its just some NFO files for my blog, u know, ads
i didn't post it herem cuz i thought it would be spam, showing my blogs name
u understand now?  ;)

thank you both  ;D
Sorry, we dont know if you are a noob or not :)
I did remove your file, please just post the source of the file.

Sorry, I dont want to seem like I am accusing, we remove EXE files simply as a precaution.

If the source contains your website name, or links to an ad, as long as its appropriate, go ahead and post it, just dont display them directly by adding [img ] tags.
Title: Re: copy 3 files to every directory in a certiain folder
Post by: ehsan_08 on August 21, 2008, 08:24:24 PM
yeah, im sorry
and about the exe files too
i was just trying to not break the rules :-\

well, i finished what i need it
thanks