forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help point me in the right direction

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
flypaper
Contributor
Contributor


Joined: 19 Oct 2001
Posts: 104

PostPosted: Fri Sep 13, 2002 12:29 pm    Post subject: Help point me in the right direction Reply with quote

I need to write a program to search and replace in filenames in a certain folder. Can someone give me some idea for this? How can I search for a filename, and then rename it? Sorry, seems a really dumb question.
Back to top
View user's profile Send private message
Protected
Valued Contributor
Valued Contributor


Joined: 02 Jan 2001
Posts: 228
Location: Portugal

PostPosted: Fri Sep 13, 2002 12:34 pm    Post subject: Reply with quote

Well, you can use LIST FILELIST to make a list with the files in a folder. Then you can either make a loop for the program to verify the items one by one, and then do the desired action (FILE command can replace filenames) or you can use @match() to search for the filenames you want to replace, and then rename them (a loop would be required too).
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Fri Sep 13, 2002 12:35 pm    Post subject: Reply with quote

You can create a list and then populate it with all the files
within the folder then repeat throught it and fine the file you
want. Something like this:

Code:

%%found =
%%file = autoexec.bat
List create,1
list filelist,1,C:\*.*
%x = 0
repeat
%i = @name(@item(1,%x)).@ext(@item(1,%x))
if @equal(%i,%%file)
%%found = 1
end
%x = @succ(%x)
until @equal(%x,@count(1))
if %%found
Info File Found!
end

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
flypaper
Contributor
Contributor


Joined: 19 Oct 2001
Posts: 104

PostPosted: Fri Sep 13, 2002 12:49 pm    Post subject: Reply with quote

Thanks guys. Sometimes you just need someone to smack you in the face w/ the obvious. Cool
Back to top
View user's profile Send private message
Que
Valued Newbie


Joined: 25 Aug 2001
Posts: 38
Location: Newaygo, MICH

PostPosted: Fri Sep 13, 2002 2:39 pm    Post subject: Reply with quote

Remember - Depending on how you are searching that @match only searches the list from the current record forward. Use list seek,listname,0
at the end of your repeat if you need to search the entire list each time.

Quote:
@MATCH( <list>, <string> )

Description:

This function returns 1 (true) if a string in the string list <list>, starting from the current pointer position, contains text matching <string>.

Copyright 1995 - 2002 S.A.D.E. s.a.r.l. / All rights are reserved.

_________________
Que
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Sep 13, 2002 9:30 pm    Post subject: Reply with quote

Que wrote:
Remember - Depending on how you are searching that @match only searches the list from the current record forward. Use list seek,listname,0
at the end of your repeat if you need to search the entire list each time.



Good point Que, Wink

Also, if searching for the same string again, you must increment
the current index by one. Otherwise, @match() will continue to
find the current position if the string was found...

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Protected
Valued Contributor
Valued Contributor


Joined: 02 Jan 2001
Posts: 228
Location: Portugal

PostPosted: Fri Sep 13, 2002 9:35 pm    Post subject: Reply with quote

When I use @match(), I simply copy all the contents to another list, then everytime it finds something I delete that thing, that way it never finds the same item twice... also after finding the item with @match() its possible to use @pos() to find the match inside the list item. But, anyway, I think using LIST SEEK or @item(x,y) to search all the list items one by one in a loop, is a much better way
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sat Sep 14, 2002 2:13 pm    Post subject: Reply with quote

Protected wrote:
But, anyway, I think using LIST SEEK or @item(x,y) to search all the list items one by one in a loop, is a much better way


Of course using that in a loop will be much slower than simply using the @match() function.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Sep 14, 2002 6:03 pm    Post subject: Reply with quote

Here's the problem with @match()..... Years ago I made a search
program and I used @match(). It works ok, but the problem is, if your
search string is contained within another word, it will also show up as a
result. Say you were searching for "Stan". @match() will find that and
any other words that have "Stan" in it, such as "Stands". Now to get
around this, if your list only contains one word in each item, you can
compare the resulting item and search string with @len(). If they both
have the same @len(), then it's a perfect match. But if each item in the
list contains more than one word, you'll have to do a bit of work to parse
that line to get the whole word and see if it does match or not.

-Garrett
Back to top
View user's profile Send private message
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 766
Location: Eastman, GA

PostPosted: Sun Sep 15, 2002 12:28 am    Post subject: Reply with quote

I think the way to overcome the problem Garrett mentioned would be to include an extra space

%%match = @match(list1,"Stan ")

NodNarb
Back to top
View user's profile Send private message AIM Address
Protected
Valued Contributor
Valued Contributor


Joined: 02 Jan 2001
Posts: 228
Location: Portugal

PostPosted: Sun Sep 15, 2002 12:42 am    Post subject: Reply with quote

Quote:
Of course using that in a loop will be much slower than simply using the @match() function.


I dont know... I dont trust @match(), at least examining every item you're sure it retrieves everything, even being slower
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
moke
Contributor
Contributor


Joined: 02 Jan 2002
Posts: 162

PostPosted: Fri Sep 20, 2002 5:26 pm    Post subject: Reply with quote

I don't trust it either, but i do use it. I don't know if it helps speed but i now try to use @ match to find the string then If @equal to verify it is what i want. It seemed like it might speed up things instead of checking every list item.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group