I have used 2 methods of renaming.
Usually they work good.
However sometimes when I go down a list of files, one or more of them will not rename.
I open Windows explorer, make a little change in the filename, and then my program will rename them.
So, it is in a list of files.
This happens in a situation where I never opened them.
But if I did accidentally open them, only a rare file, in a list, is affected, none of the others.
I am also curious why my function at the bottom will not rename files with foreign characters.
I thought it might work better than FileRename.
If they seem a little "wordy", its to make them easier to debug.
Also, there is no problem with the new file names. I checked that out carefully.
My renamed files get rid of questionable and junk characters, simplifies the name and gives them some common structure.
BTW, You have been kind to me. I appreciate that. I am old now, sometimes things get past me.
I have a few things to finish up while I can. I miss the old days when a hacker was a good guy.
Thank the ignorant media for that one. It was Phreakers who did the bad "hacking".
They never said a word about them. They turned a whole generation of us into criminals.
// Rename 1
TShellTreeView OnChange:
ActiveDir := IncludeTrailingPathDelimiter(STV1.Path);
OnClickEvent:
For I := 0 to ActiveList.Items.Count - 1 do
begin
If ActiveList.Items.Item.Selected then
begin
FN := ActiveList.Items.Item.Caption;
NFN := FN;
// File Name altered here
RenameFile(ActiveDir + FN, ActiveDir + NFN);
end;
end;
// Rename2
I := 0;
While I < Selected.FileList.Items.Count do
begin
If Selected.FileList.Items.Item.Selected then
begin
C := Selected.FileList.Items.Item.Caption;
If MoveAFile(FileIn, FileOut) then
Selected.FileList.Items.Item.Caption := C;
// This function will not rename files with foreign characters
Function TWork.MoveAFile(StrFrom, StrTo: string): Boolean;
var
F : TShFileOpStruct;
begin
F.wFunc:=FO_MOVE;
F.pFrom:=PChar(StrFrom+#0);
F.pTo:=PChar(StrTo+#0);
F.fFlags := FOF_RENAMEONCOLLISION or FOF_NOCONFIRMMKDIR or FOF_NOCONFIRMATION or FOF_SILENT;
if ShFileOperation(F) <> 0 then
result:=False
else
result:=True;
end;