#1 2016-07-02 10:35

borsh4
Member
Registered: 2016-07-02
Posts: 2

Renaiming folders by using information from names of file on it

I have situation like this:

Folder1/file1_123.jpg
Folder1/file2_123.jpg
...
Folder1/fileX_123.jpg

Folder2/file1_4567.jpg
Folder2/file2_4567.jpg
...
Folder2/fileX_456.jpg

Result I want to have like that (I'm interested only on renaming a folders):

Folder1_123/file1_123.jpg
Folder1_123/file2_123.jpg
...
Folder1_123/fileX_123.jpg

Folder2_4567/file1_456.jpg
Folder2_4567/file2_456.jpg
...
Folder2_4567/fileX_456.jpg

Realy nothing knows in Pascal.
Thanks for any help.

Offline

#2 2016-07-02 11:00

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Renaiming folders by using information from names of file on it

Hi and welcome borsh4.

FROM:
Folder1\file1_123.jpg

TO:
Folder1_123\file1_123.jpg


In other words:

- for each folder
- from first file in folder ......... take part after last underscore
- rename folder by adding that part as suffix

???


If yes, this should be doable.

Here is a similar script of renaming folders based on files in folder, could be adopted.
    Index
    » ReNamer
    » Looking for script - rename folders to number of files inside
http://www.den4b.com/forum/viewtopic.php?id=2011


Will do it for you once I know exactly what you want and if I find some free time.


 


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

#3 2016-07-02 11:16

borsh4
Member
Registered: 2016-07-02
Posts: 2

Re: Renaiming folders by using information from names of file on it

Anyone file in folder have some suffix - for example 123,
in other folder some other suffix - for example 1597

any time it's numbers.

This sufix I want to take (copy) and paste as suffix in folder where there those files a lives.
Thanks for your answer.

Trying to learn scripts from link you take to me.

Offline

#4 2016-07-02 11:23

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Renaiming folders by using information from names of file on it

FROM:
Folder1\file1_1234567.jpg

TO:
Folder1_1234567\file1_1234567.jpg

TRY:
- Check the filter:
--- to not include files
--- to add a folder as a file
- Add Folder
- Use this script below

var 
  Filesarray:TStringsArray;
  FirstFile,UnderscorePart:WideString;
begin
  WideScanDirForFiles(FilePath, Filesarray,False,False,False,'*');
  FirstFile      := Filesarray[0];
  //RegEx matching all after last underscore of: file1_123.jpg, file2_4567.jpg
  UnderscorePart := ReplaceRegEx(FirstFile,'.+(_.+)\....$','$1', False, True);

  showmessage(FileName + UnderscorePart);
//  FileName := FileName + UnderscorePart;
end.

How to use >> http://www.den4b.com/wiki/ReNamer:Rules:PascalScript



 

Last edited by Stefan (2016-07-02 12:05)


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

Board footer

Powered by FluxBB