You are not logged in.
Pages: 1
Hello, this is my current code.
var
i: Integer; ParentDir1, ParentDir2: WideString;
begin
ParentDir1 := WideExtractFileDir(FilePath);
ParentDir2 := WideExtractFileName(ParentDir1);
i := i + 1;
FileName := ParentDir2 + '-' + IntToStr(i);
end.
What I want to do is to completely modify the file name, and the rule is to add the parent folder name and sequence number.
This code can successfully name a single folder after dragging it in. But when I drag multiple folders, the sequence number will continue from the previous folder to the next, and the second folder does not start from 1. What should I do?
For example, the result I want is 1-1,1-2,1-3,2-1,2-2,2-3
But the result after running the above code is, 1-1, 1-2, 1-3, 2-4, 2-5, 2, 6
Also, after using this code, the extension disappeared. How can I keep it?
Last edited by SleepGlasses (2023-10-24 05:12)
Offline
Can you provide a complete example with a list of original file paths and the desired new news?
The extension part is easy, you can append it at the end:
FileName := FileName + WideExtractFileExt(FilePath);
Offline
Yes,
Before:
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\1\1V3A3597.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\1\1V3A3598.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\1\1V3A3599.jpg
.....
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\29\1V3A3720.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\29\1V3A3721.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\29\1V3A3722.jpg
I want after:
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\1\1-1.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\1\1-2.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\1\1-3.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\1\1-4.jpg
......
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\2\2-1.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\2\2-2.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\2\2-3.jpg
.......
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\3\3-1.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\3\3-2.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\3\3-3.jpg
.......
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\4\4-1.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\4\4-2.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\4\4-3.jpg
......
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\29\29-1.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\29\29-2.jpg
D:\文件\拍卖\9月\第三期第二场\第三期第二场细节图\29\29-3.jpg
The actual files are much more than here.
Last edited by SleepGlasses (2023-10-25 05:59)
Offline
You can do this without the Pascal Script rule, with just these rules:
1) Insert: Insert ":File_FolderName:-" replacing current name (skip extension)
2) Serialize: Incremental from 1 repeat 1 step 1 (reset index if folder changes) as Suffix (skip extension)
Offline
You can do this without the Pascal Script rule, with just these rules:
1) Insert: Insert ":File_FolderName:-" replacing current name (skip extension)
2) Serialize: Incremental from 1 repeat 1 step 1 (reset index if folder changes) as Suffix (skip extension)
Thank you very much for your guidance, now I can use it smoothly! ! !:lol::lol::lol:
Offline
Pages: 1