Solved

make search and edit batch script faster...

Posted on 2012-03-13
1
297 Views
Last Modified: 2012-08-14
The below script works fine.  Just a little slow.  It is because it is searching so many drives.   but is there a way to make the script 'faster"? Even a second or two would be nice

One thing I should mention is, the "bquest" folder would be located somewhere in the folder %programfiles%.  maybe we can edit this to go directly to that directory first...

@echo off
(for %%i in (C D E F G) do (dir %%i:\*bquest /s /b /ad))>dir_search.txt
for /f "tokens=* delims=" %%x in (dir_search.txt) do (
    if not exist "%%x\keycode" (  
    copy /v /y etkey "%%x\keycode" >NUL 2>&1
    attrib +r "%%x\keycode" >NUL 2>&1
  )
)
0
Comment
Question by:icecom4
1 Comment
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 37722675
Hi, one way to make it faster would be to change
(dir %%i:\*bquest /s /b /ad)
to
(dir %%i:\program files\*bquest /s /b /ad)

Note: You need to hardcode Program Files instead of %programfiles% because the %programfiles% variable contains a drive letter.

Another way to make it faster would be to create a separate batch file for each drive, as in

(dir "C:\Program Files\*bquest" /s /b /ad))>dir_search.txt
for /f "tokens=* delims=" %%x in (dir_search.txt) do (
    if not exist "%%x\keycode" (  
    copy /v /y etkey "%%x\keycode" >NUL 2>&1
    attrib +r "%%x\keycode" >NUL 2>&1
  )
)

Open in new window


and
(dir "D:\Program Files\*bquest" /s /b /ad))>dir_search.txt
for /f "tokens=* delims=" %%x in (dir_search.txt) do (
    if not exist "%%x\keycode" (  
    copy /v /y etkey "%%x\keycode" >NUL 2>&1
    attrib +r "%%x\keycode" >NUL 2>&1
  )
)

Open in new window


etc, and then kick them all off at the same time.  This way you search each drive concurrently, instead of sequentially.

Regards,

Rob.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Utilizing an array to gracefully append to a list of EmailAddresses
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now