You are not logged in.
Greetings,
I want to rename files that have same name as its folder only,
tried my luck with using a meta tag on the find panel instead of the replace panel:
not suprisingly, it did not work...
if it did, i could rename 9000 models...
is it possible to get it done via pascal script or alike inside renamer?
Last edited by crystal3d (2011-08-16 15:51)
Offline
I think this should be easy with PascalScript, but I found something unexpected.
One question for Denis: Shouldn't WideExtractFileDir() return the folder name instead of the folder path? for the folder path there's already WideExtractFilePath(), isn't it?.
Last edited by SafetyCar (2011-08-16 19:49)
If this software has helped you, consider getting your pro version. :)
Offline
Greetings,
I want to rename files that have same name as its folder only,is it possible to get it done via pascal script
FROM:
X:\Path\to\Test\Test.ext
X:\Path\to\Test\File.ext
TO:
X:\Path\to\Test\_Test.ext
X:\Path\to\Test\File.ext
Try:
var
ParentFolder,FileBase: WideString;
begin
ParentFolder := CalculateMetaTag(FilePath, ':File_FolderName:');
FileBase := WideExtractBaseName(FileName);
if (FileBase=ParentFolder) then
FileName := '_' + FileName;
end.
If Parent and File have different case,
FROM:
X:\Path\to\Test\test.ext
TO:
X:\Path\to\Test\_test.ext
Try:
var
ParentFolder,FileBase: WideString;
begin
ParentFolder := CalculateMetaTag(FilePath, ':File_FolderName:');
FileBase := WideExtractBaseName(FileName);
ParentFolder := WideLowerCase(ParentFolder);
FileBase := WideLowerCase(FileBase);
if (FileBase=ParentFolder) then
FileName := '_' + FileName;
end.
If Parent and File have different case,
but the file should get the same case as the parent folder
FROM:
X:\Path\to\Test\test.ext
TO:
X:\Path\to\Test\_Test.ext
Try something like:
var
ParentFolder,FileBase: WideString;
begin
ParentFolder := CalculateMetaTag(FilePath, ':File_FolderName:');
FileBase := WideExtractBaseName(FileName);
ParentFolder := WideLowerCase(ParentFolder);
FileBase := WideLowerCase(FileBase);
if (FileBase=ParentFolder) then
FileName := '_' + CalculateMetaTag(FilePath, ':File_FolderName:');
end.
HTH?
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Here is a good article which gives examples of how functions like ExtractFileDir behave:
http://www.delphibasics.co.uk/RTL.asp?N … actFileDir
I have also fixed the description of these functions on the Wiki:
ReNamer:Pascal_Script:Functions#File_Name_Utilities
To extract folder name of a file, you can use this snippet:
FileName := WideExtractFileName(WideExtractFileDir(FilePath));
Offline
Bull's eye! DTH!
Offline
crystal3d, thanks for the feedback! (your long quoting will be removed later )
To extract folder name of a file, you can use this snippet:
FileName := WideExtractFileName(WideExtractFileDir(FilePath));
Thanks
Added to the wiki http://www.den4b.com/wiki/ReNamer:Pasca … :SplitPath
(re-formating allowed )
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline