Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-22-2013, 09:03 PM   #1
Baseband Member
 
palermo's Avatar
 
Join Date: Jan 2013
Location: United States
Posts: 81
Default Batch Scripting

I wrote this to search my folder for all .doc files but it is not working, please help

@echo off
for %%c (c:\john\\*.doc) do echo %%c

I'm not typing it directly into the CL, I know that it doesn't like double %'s for variables
__________________

palermo is offline   Reply With Quote
Old 05-22-2013, 10:57 PM   #2
Fully Optimized
 
OhSnapWord's Avatar
 
Join Date: Jan 2012
Location: USA
Posts: 1,853
Default Re: Batch Scripting

I'm not any good at scripting but the "\\" is my best guess.
__________________

__________________
FX-8350 @ 4.7 cooled by H80, 32GB Mushkin Enhanced Blackline 2133, Asus Sabertooth 990FX, 2x Radeon HD 7850 2GB in X-fire, 500GB Samsung 850 Evo, 4TB Seagate, 3TB WD Black, 2x 1TB WD RED in RAID 0
OhSnapWord is offline   Reply With Quote
Old 05-23-2013, 08:49 AM   #3
Wizard of Wires
 
setishock's Avatar
 
Join Date: Feb 2005
Location: Not sure
Posts: 10,030
Default Re: Batch Scripting

Quicker to just open the search box from the start button and type in .doc.
setishock is offline   Reply With Quote
Old 05-23-2013, 09:51 AM   #4
Fully Optimized
 
strollin's Avatar
 
Join Date: Mar 2011
Location: USA
Posts: 1,938
Default Re: Batch Scripting

You left out the word "in" in the For command and you have an extra \ in there. Try:

@echo off
for %%c in (c:\john\*.doc) do echo %%c
strollin is offline   Reply With Quote
Old 05-23-2013, 11:49 AM   #5
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Batch Scripting

This is where *nix shell scripting is just, well, better!

find /usr/john -name *.doc

__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 05-23-2013, 12:13 PM   #6
Fully Optimized
 
strollin's Avatar
 
Join Date: Mar 2011
Location: USA
Posts: 1,938
Default Re: Batch Scripting

Seems about the same to me, not necessarily better or easier, just different.

The OP could actually just use the DIR command to accomplish the same thing:

@Echo off
dir c:\john\*.doc /B
strollin is offline   Reply With Quote
Old 05-23-2013, 07:30 PM   #7
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Batch Scripting

Quote:
Seems about the same to me, not necessarily better or easier, just different.
I was referring to the lack of a loop, but as you pointed out the dir command can do it pretty similarly.
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 05-23-2013, 10:12 PM   #8
Baseband Member
 
palermo's Avatar
 
Join Date: Jan 2013
Location: United States
Posts: 81
Default Re: Batch Scripting

Thanks for all the help. I finished UNIX shell scripting last week, I just started Windows batch scripting. Tonight's homework is to create a batch backup script to make a copy of each file and rename it with a different format. Then use commands to schedule the script to run daily...fun stuff.
__________________

palermo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:24 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0