![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Feb 2008
Posts: 325
OS: Vista
|
.BAT Commands
Hey, I need some help with a .bat program.
I need to code a script that will copy all the files in a certain directory and paste them to another specified directory. So for example, the user will be prompted with the .bat file asking what the full path to the directory of the files are. Then it will copy all the files in that directory and paste them into C:\directory_name_here. Thanks in advance. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,884
OS: Vista, various linux distros
|
Re: .BAT Commands
Hey, i think something like this will do it:
Code:
@ECHO OFF rem Prompt for the directory set /p theDirectory="Please type the name of the directory: " rem if it doesnt exist jump to the error IF NOT EXIST %theDirectory% GOTO NOTFOUND rem else copy the files copy %theDirectory%\* C:\directory_name_here\ rem and output a nice message ECHO Files copied from %theDirectory% to C:\directory_name_here rem goto the end of the file(skipping the error) GOTO END :NOTFOUND ECHO The directory %theDirectory% could not be found :END pause Cheers, Jamey |
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Feb 2008
Posts: 325
OS: Vista
|
Re: .BAT Commands
Also, I want this program to run everytime someone starts their computer if they set it to. Is there a way to store a setting? Like if %arg1% = yes then it will run on startup elseif $arg1% = no it won't. The purpose of this is to keep the 2 folders in sync. Also, is there a way to limit the files that are being copied to .mp3's only?
|
|
|
|
|
|
#7 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,884
OS: Vista, various linux distros
|
Re: .BAT Commands
I don't know of a way to store a setting, other than maybe reading and writing to a file and the program would have to run on every startup whether it's supposed to or not and then just skip syncing or not.
The routine could go something like: Code:
IF NOT EXIST settings.txt GOTO SKIP :FOUND for /F %%x in (settings.txt) do (if %%x==1 GOTO SKIP) rem the rest of the code would go here echo this code will be run if the settings are set to 0 echo else it will be skipped :SKIP To limit the files being copied you could change Code:
copy %theDirectory%\* C:\directory_name_here\ Code:
copy %theDirectory%\*.mp3 C:\directory_name_here\ Cheers, Jamey |
|
|
|
|
|
#10 (permalink) |
|
Moderator, Microsoft Supp
Join Date: Sep 2007
Location: The Great State of New Jersey - away from the gross corruption of the Riverside County, CA, SO office. SHAMEFUL !
Posts: 10,132
OS: Windows 7, Vista Ultimate
|
Re: .BAT Commands
Hi. . .
To save ipconfig ionfo - @ the cmd prompt type: Code:
ipconfig /all > "%userprofile%\documents\ipconfig.txt" Any others? Ask away! Regards. . . JC . |
|
|
|
|
|
#11 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,884
OS: Vista, various linux distros
|
Re: .BAT Commands
Well in the example i gave you i'd tested it, you could use a full or relative path. (in the example "settings.txt" was in the same folder)
Last edited by jamiemac2005; 10-13-2008 at 09:55 AM. |
|
|
|
|
|
#13 (permalink) |
|
Design Team Member
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,884
OS: Vista, various linux distros
|
Re: .BAT Commands
Glad to help, post back if you have any more problems. I know it's a little off topic but you can "convert" batch files to .exes as if they're compiled using this tool: http://www.f2ko.de/English/b2e/download.php
I use it now and then to avoid people modifying my programs, ruining their computer and blaming me. It can also be used to just hide source code, etc. (Numerous advantages over having a batch file.) Cheers, Jamey |
|
|
|
![]() |
| Thread Tools | |
|
|