You are not logged in.
First of , really thanks to Denis Kozlov making a wonderful program . I just discover the renamer during google search which really help renaming a batch of files.
I am newbie , doesn't know much on programing.Right now , I'd like to know how to backup and undo rename files ?
Lets say I rename a file , I wanted to backup the original file name.It's easier to view it on a slideshow using short name.But , after I rename it , I can't undo rename
Eg.
[Current Name] [New Name]
PC10001.JPG > PC1.JPG
PC10031.JPG > PC2.JPG
I did 'Export file paths and new names' but after rename and close the renamer program.I felt , I wanted to undo the rename.I "Import file paths and new names" but press CTRL+Z doesn't work , Undo button doesn't work.
How do I undo rename ? Switch place from new name back to current name ? since I make a backup on 'Export file paths and new names' to .csv (excel format) or .txt format ?
Eg.
[Current Name] [New Name]
PC10001.JPG < PC1.JPG
PC10031.JPG < PC2.JPG
Really appreciate anyone can help out.Thank you
Offline
Did make it too complicated ? sorry if I did.
In short , backup [Current Name] and [New Name] into a text fine.How do I Restore it back to [Current Name] by matching the [New Name]. ?
Thank you
Offline
Well, I'm not 100% sure that this is going to work but...
On backup_file you should change the path for the one where your backup is.
If it's not working might be mainly because two reassons:
1: The type of delimiters on the backup (CSV uses quotations and commas, TXT uses tabulations)
2: Checking for a name when a we should search for a path instead.
Both things are solvable but we must know them first.
Give it a try
const
backup_file = 'C:\names_backup.txt';
var
BackupLines, Pair, OldNames, NewNames: TStringsArray;
I: Integer;
Init, Cancel: Boolean;
begin
if (Cancel) then Exit;
if (not Init) then
begin
Init := True;
If (not WideFileExists(backup_file)) then
begin
WideShowMessage('Backup file not found on the especified path, ' +
'please check it again.')
Cancel := True;
Exit;
end;
// #13#10 => Carriage Return + Line Feed
BackupLines := WideSplitString(FileReadContent(backup_file), #13#10);
SetLength(OldNames, Length(BackupLines));
SetLength(NewNames, Length(BackupLines));
for I:=0 to Length(BackupLines)-1 do
begin
// #9 => Tabulation char
Pair := WideSplitString(BackupLines[i], #9);
if (Length(Pair) = 2) then
begin
OldNames[i] := Pair[0];
NewNames[i] := Pair[1];
end;
end;
end;
for I:=0 to Length(NewNames)-1 do
begin
If (NewNames[i] = FileName) then
begin
FileName := OldNames[i];
Break;
end;
end;
end.
Last edited by SafetyCar (2012-11-01 20:58)
If this software has helped you, consider getting your pro version. :)
Offline
Thanks a lot it works ! .Very happy with it which I am able to restore the current name from new name.Thanks SafetyCar.
If the restore name isn't valid , it still show complete rename without error.Possible to list out the error if fail to rename ?
If the new name doesn't match the old name when rename or during preview , it doesn't show a red X sign on the state.Possible to add into the script ?
Actually it already fulfill my needs , just an addition Thanks a lot
Offline
Welle the scripts have some limitations respect the user interface, but you can force it to trigger an error by adding an invalid name, for example using characters not allowed (by windows) in the name.
For example, you could add this to set as default name when there are no matches:
FileName := ':: Name not found on the backup ::';
Just before:
for I:=0 to Length(NewNames)-1 do
If this software has helped you, consider getting your pro version. :)
Offline
Welle the scripts have some limitations respect the user interface, but you can force it to trigger an error by adding an invalid name, for example using characters not allowed (by windows) in the name.
For example, you could add this to set as default name when there are no matches:
FileName := ':: Name not found on the backup ::';Just before:
for I:=0 to Length(NewNames)-1 do
You mean here ?
// #13#10 => Carriage Return + Line Feed
BackupLines := WideSplitString(FileReadContent(backup_file), #13#10);
SetLength(OldNames, Length(BackupLines));
SetLength(NewNames, Length(BackupLines));
FileName := ':: Name not found on the backup ::';
for I:=0 to Length(BackupLines)-1 do
begin
// #9 => Tabulation char
Pair := WideSplitString(BackupLines[i], #9);
if (Length(Pair) = 2) then
begin
OldNames[i] := Pair[0];
NewNames[i] := Pair[1];
Tried it , even correct file name show "name not found" , did put it at the corrent line ? sorry if I make any mistake .
Offline
You mean here ?
Nope, there is one very similar line at the bottom of the script, almost at the end, do you see it now?
If this software has helped you, consider getting your pro version. :)
Offline
Dfmu wrote:You mean here ?
Nope, there is one very similar line at the bottom of the script, almost at the end, do you see it now?
// #9 => Tabulation char
Pair := WideSplitString(BackupLines[i], #9);
if (Length(Pair) = 2) then
begin
OldNames[i] := Pair[0];
NewNames[i] := Pair[1];
end;
end;
end;
FileName := ':: Name not found on the backup ::';
for I:=0 to Length(NewNames)-1 do
begin
If (NewNames[i] = FileName) then
begin
FileName := OldNames[i];
Break;
end;
end;
end.
Correct ? but it still show the same result ,sorry again
Offline
How the same result? what result?
Are you sure about the backup you are using?
Also if you have already reverted the names it will show that message, because they are no longer found with the previous names.
If this software has helped you, consider getting your pro version. :)
Offline
Ugh, I forgot something on my previous script i edited it, please update it with the following
But this fixes it shouldn't be related with what you were talking about
const
backup_file = 'C:\names_backup.txt';
var
BackupLines, Pair, OldNames, NewNames: TStringsArray;
I: Integer;
Init, Cancel: Boolean;
begin
if (Cancel) then Exit;
if (not Init) then
begin
Init := True;
If (not WideFileExists(backup_file)) then
begin
WideShowMessage('Backup file not found on the especified path, ' +
'please check it again.')
Cancel := True;
Exit;
end;
// #13#10 => Carriage Return + Line Feed
BackupLines := WideSplitString(FileReadContent(backup_file), #13#10);
SetLength(OldNames, Length(BackupLines));
SetLength(NewNames, Length(BackupLines));
for I:=0 to Length(BackupLines)-1 do
begin
// #9 => Tabulation char
Pair := WideSplitString(BackupLines[i], #9);
if (Length(Pair) = 2) then
begin
OldNames[i] := Pair[0];
NewNames[i] := Pair[1];
end;
end;
SetLength(BackupLines, 0);
end;
FileName := ':: Name not found on the backup ::';
for I:=0 to Length(NewNames)-1 do
begin
If (NewNames[i] = FileName) then
begin
FileName := OldNames[i];
Break;
end;
end;
end.
Last edited by SafetyCar (2012-11-01 21:03)
If this software has helped you, consider getting your pro version. :)
Offline