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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > Microsoft Support > Windows Vista/Windows 7 Support
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Reply
 
LinkBack Thread Tools
Old 10-12-2008, 01:36 PM   #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.
Slapshot is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 10-12-2008, 02:56 PM   #2 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
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
if you don't want to leave the files in the source directory(the one the user enters) then change "copy" to "move".

Cheers,
Jamey
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-12-2008, 04:45 PM   #3 (permalink)
Registered User
 
Join Date: Feb 2008
Posts: 325
OS: Vista


Re: .BAT Commands

Thanks Jamie, actually I had pretty much finished the script halfway but that snippet you posted was a big help. Thanks.
Slapshot is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-12-2008, 04:47 PM   #4 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,884
OS: Vista, various linux distros


Re: .BAT Commands

Thats okay =]
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-12-2008, 04:55 PM   #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?
Slapshot is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-12-2008, 09:10 PM   #6 (permalink)
Registered User
 
Join Date: Feb 2008
Posts: 325
OS: Vista


Re: .BAT Commands

And also, is there a way to disable antiviruses and firewalls temporarily via cmd commands?
Slapshot is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 06:05 AM   #7 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
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
and then settings.txt would have to have the contents "1" to skip

To limit the files being copied you could change
Code:
copy %theDirectory%\* C:\directory_name_here\
to
Code:
copy %theDirectory%\*.mp3 C:\directory_name_here\
As for the antivirus i don't think theres a way to disable all antivirus programs and each of them will have different methods so you'd have to research the specific antivirus programs to find a way.

Cheers,
Jamey
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 08:38 AM   #8 (permalink)
Registered User
 
Join Date: Feb 2008
Posts: 325
OS: Vista


Re: .BAT Commands

Thanks.

But wouldn't I need to include a full path to the .txt?
Slapshot is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 08:41 AM   #9 (permalink)
Registered User
 
Join Date: Feb 2008
Posts: 325
OS: Vista


Re: .BAT Commands

Sorry I know I'm asking a lot...

Also, is there a way to save ipconfig info?
Slapshot is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 09:24 AM   #10 (permalink)
Moderator, Microsoft Supp
 
jcgriff2's Avatar
 
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

My System

Re: .BAT Commands

Hi. . .

To save ipconfig ionfo - @ the cmd prompt type:
Code:
ipconfig /all > "%userprofile%\documents\ipconfig.txt"
Or you can copy/paste - right-click near the top of the "DOS" screen, select Edit, select Paste. The hit Enter if need be.

Any others? Ask away!

Regards. . .

JC

.
__________________
. . . . . . . .

B
Expecting a reply and waiting > 36 hours ? Send a PM to me containing a link to your thread
Glad to be home in the Great State of New Jersey ! !
jcgriff2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 09:53 AM   #11 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,884
OS: Vista, various linux distros


Re: .BAT Commands

Quote:
Originally Posted by Slapshot View Post
But wouldn't I need to include a full path to the .txt?
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)
__________________

Myspace

Last edited by jamiemac2005; 10-13-2008 at 09:55 AM.
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 10:45 AM   #12 (permalink)
Registered User
 
Join Date: Feb 2008
Posts: 325
OS: Vista


Re: .BAT Commands

Ah okay, thanks guys :)
Slapshot is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 04:07 PM   #13 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
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
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 04:35 PM   #14 (permalink)
Registered User
 
Join Date: Feb 2008
Posts: 325
OS: Vista


Re: .BAT Commands

I already use that :D
Slapshot is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-13-2008, 09:23 PM   #15 (permalink)
Design Team Member
 
jamiemac2005's Avatar
 
Join Date: Jul 2007
Location: Coventry, UK
Posts: 1,884
OS: Vista, various linux distros


Re: .BAT Commands

hah =] goodgood.
__________________

Myspace
jamiemac2005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 01:05 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85