Here is a simple program that uses a file called "details.txt" for information and renames every file in the current directory or specified directory by replacing a string of text in a file name.
The file details.txt is attached
Rem Project: Dark Basic Pro Project
Rem Created: Tuesday, May 21, 2013
Rem ***** Main Source File *****
length = 21
cls
open to read 1, "details.txt"
repeat
read string 1, string$
data$ = string$
data$ = right$(data$, len(data$) - length)
string$ = data$
read string 1, replace$
data$ = replace$
data$ = right$(data$, len(data$) - length)
replace$ = data$
read string 1, steps$
data$ = steps$
data$ = right$(data$, len(data$) - length)
steps$ = data$
steps = val(steps$)
read string 1, notify$
data$ = notify$
data$ = right$(data$, len(data$) - length)
notify$ = data$
read string 1, path$
data$ = path$
data$ = right$(data$, len(data$) - length)
path$ = data$
if path$ <> ""
set dir path$
endif
find first
print get dir$()
//Test for root directory
if get file name$() = "." then find next
if get file name$() = ".." then find next
//input "Please type text you want to replace for each file in directory :", string$
//input "Please type text you would like to replace with :", replace$
//input "Enter number of times to replace :", steps
//input "notifications (yes/no) :", notify$
notify$ = lower$(notify$)
repeat
FName$ = get file name$()
org$ = FName$
for i = 1 to steps
FName$ = ReplaceText(FName$, string$, replace$)
next i
if FName$ <> ""
if notify$ = "yes"
cls
repeat
text 0, 0, "Renaming :" + org$
text 0, 20, "To :" + FName$
text 0, 40, "Press escape to cancel"
sync
until spacekey() = 1
repeat:until spacekey() <> 1
endif
rename file org$, FName$
endif
find next
until get file type() = -1
cls
until file end(1)
close file 1
repeat
str2$ = "Completed press spacebar to end..."
text 0, 0, str2$
sync
until spacekey() = 1
repeat:until spacekey() <> 1
end
function ReplaceText(text$, chars$, replace$)
//Find the beginning position of text
ch1 = FindTextPos(text$, chars$, 1)
//Find the end position of text
ch2 = FindTextPos(text$, chars$, 2)
//Replace found text with replacement text
if ch1 > 0
string1$ = left$(text$, ch1-1)
string2$ = right$(text$, len(text$) - (ch2-1))
ReplacementString$ = string1$ + replace$ + string2$
else
ReplacementString$ = text$
endif
endfunction ReplacementString$
function FindTextPos(text$, textfd$, value)
FoundVal$ = ""
for ch = 1 to len(text$)-4
//if the currect character is same as the first character in the text to find then
if mid$(text$, ch) = mid$(textfd$, 1)
FoundVal$ = ""
i = 0
retTemp = 0
repeat
//if the next character is found in the text then add
retTemp = 0
if mid$(text$, ch + i) = mid$(textfd$, i + 1)
retTemp = 1
endif
i = i + 1
until i = len(textfd$) or ch + i > len(text$) or retTemp = 0
//if found all characters in text return the first or last position
if retTemp = 1
if value = 1 then ret = ch
if value = 2 then ret = ch + i
endif
endif
next ch
endfunction ret
If you find any errors or have suggestions feel free to let me know.