Batch Renaming Folders

Started by Mike, May 10, 2023, 11:34:58 AM

Previous topic - Next topic

Mike

I suggest making batch renaming of folders possible. This would make it much easier to quickly implement helpful or even necessary naming concepts.

Right now I have 8000 folders to rename, but it doesn't have to be that extreme. Even for groups of a few dozen folders, a batch renaming would be very welcome. Sometimes you want to add prefixes or suffixes, maybe add a date to the name or just change the spelling... It can also happen, that you have to change characters, because they would otherwise be incompatible in a certain environment, etc.

It would be a more complete file management solution overall.

Thanks!

Mike

#1
Relocate hierarchies of renamed folders?

As I understood, programming an internal batch folder renaming would be a tedious task. But how about a partial solution? This might be useful in other cases as well.

At the moment: Using the relocate action, iMatch can reconnect the contents of an externally renamed parent folder to the database. Contained child folders are only recognized if they have not been renamed and not moved in the hierarchy.

I don't know if my non-programmer point of view is wrong, but renaming and then relocating might look something like this:

1.The folders would be externally renamed with any other software capable of batch renaming. So that would no longer have to be programmed.

2.SMART-RELOCATE ;-) - a new iMatch feature or app would scan the folders and "recognize" them by their names if not changed, but also by the files they contain, if folder have been renamed. In fact, groups of specific files are probably relatively unique and therefore potentially re-identifiable (individually or as a group based on various properties - name, number, size etc. or even content). This would theoretically ensure that iMatch also recognizes unnamed folders again. Of course, if I'm not imagining it wrong.

So we would explicitly show iMatch which is the parent folder. iMatch would "recognize" the child folders based on the files they contained, whether the folders were renamed or not. New names would be adopted in place of the old ones. If anything is unclear, we may be asked to manually approve some of the recognitions.

Such a solution - if possible at all - could also hide risks, but if one is warned under which circumstances this approach is risky/acceptable, then interested users could decide for themselves.

If this were possible, we could easily reconnect a large number of renamed folders to the database at once and save a lot of time.

Am I imagining something that doesn't work in terms of programming, or requires more effort than it makes sense?

Mario

Quote1.The folders would be externally renamed with any other software capable of batch renaming. So that would no longer have to be programmed.

2.SMART-RELOCATE ;-) - a new iMatch feature or app would scan the folders and "recognize" them by their names if not changed, but also by the files they contain, if folder have been renamed. 
Such a solution would be quite error prone and a bad idea. Trying to figure out how a folder was renamed or moved by the user by analyzing the files it contains. It could be done, by file name, size and checksum, but why?

Renaming a folder from an IMatch script is an easy thing do do. And this avoids the relocate step, since IMatch does that automatically.

What could probably be more challenging is the "how to rename" part. I doubt what you have in mind would be as simple as cropping some parts of the folder name or adding a prefix or suffix. This sounds more like something that would require different modes, steps, maybe even regexp-replacements to handle all cases. Also doable, but a lot more work.

Yesterday I've showed you a code snippet that iterates over all folders in your database.
In that loop, one only would have to identify if a folder has to be renamed and how, and then call the v1/folder/rename endpoint  to rename the folder (on disk and in the database).

Hard-coding something like this for a specific purpose / naming convention is way easier than coming up with a flexible solution that works for many users, has a neat UI, documentation and is included in the regular IMatch maintenance task.
If you don't know anybody who can program in PowerShell or Python or similar, maybe some of the friendly folks in this community will step in if you provide exact details about how to identify the folders to be renamed and how to rename them.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mike

Thanks for the explanations. I can very well understand all that. I haven't looked into scripting yet, just brainstorming until I really have time to actually tackle it.

The bare minimum to start with would be character substitution in folder names. That is, only what already exists would be replaced by something else in the same location. So no reordering, no complex prefixes or suffixes, etc.

Example: it would replace all commas, brackets, & and spaces as well as letters such as ö, ä, ü, ß, é, è, å etc. with other characters or letters. E.g. the typical ae, oe, ue instead of ä, ö, ü and so on.

I would think about more luxurious solutions that work like today's file renaming later, if it is still necessary (technology situation is constantly changing)

Mario


QuoteExample: it would replace all commas, brackets, & and spaces as well as letters such as ö, ä, ü, ß, é, è, å etc. with other characters 
You can do all that when you write a script or find somebody to write you a script.
This is already a "replace x with y" table to setup and process in the script. And I bet there are some special cases to deal with on top. Always the case.

Side note: this is why most pro's use plain ASCII folder and file names. No Umlauts, no special characters, especially no blanks, just plain ASCII characters and digits. Especially if one works across multiple platforms.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mike

Quote from: Mario on May 12, 2023, 02:41:39 PMAnd I bet there are some special cases to deal with on top.
I have no doubts about that! I can already see "the trains" derailing because I forgot a "button" ;-)

Quote from: Mario on May 12, 2023, 02:41:39 PMSide note: this is why most pro's use plain ASCII folder and file names.
That's exactly what I always thought, but I had to live with folders that were automatically created from information that didn't use this spelling. Not out of ignorance, but because it was extracted directly from normal text and without reformatting due to technology. Fortunately, things will be very different in the future. Unfortunately, the many existing folders still have to be renamed.

I'll take care of that when the time comes.


Damit

Is there any caveat to using an external program, like Bulk Rename Utility (great free utility program) to rename your folders and files, and then re-import them to iMatch? Would relocator be useful for reintegrating the files instead of re-importing them.  This is an issue I have considered when changes in workflow may demand filename changes.

Mario

Quote from: Damit on May 24, 2023, 03:24:20 PMIs there any caveat to using an external program, like Bulk Rename Utility (great free utility program) to rename your folders and files, and then re-import them to iMatch? Would relocator be useful for reintegrating the files instead of re-importing them.  This is an issue I have considered when changes in workflow may demand filename changes.
When you rename or move files outside of IMatch, you will have to relocate them in your database, not add them again.

See Off-line Folders and Files for why this is important.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook