Subject: Re: [Name Mangler Talk] Rename .txt files with 1st line of text

From: Rob Griffiths <[email-masked]>
Date: Thu, 8 Jul 2021 08:26:21 -0700

On Jul 6, 2021, at 11:03 PM, Gsazraetr <[email-masked]> wrote:

> What I meant was that, in the context of your previous answer ("you'll either have to find a way to pull the first lines of text from the file into a macOS metadata field, or use a tool that can read files while renaming"), I wonder if the first of these approaches might be more straightforward. Like with the UNIX core commands, do you already have some idea of how to do this?

There's no metadata that contains any part of the file's content, but yes, it's obviously possible to read text from a file. The feature can be done, but it's non-trivial and will complicate the UI of the app, because we'll have to provide some way to not only retrieve the text, but let the user manipulate it. We're aware of the interest, and it's on the list of possible future features.

regards;
-rob.

---

From: Gsazraetr <[email-masked]>
Date: Tue, 6 Jul 2021 23:03:21 -0700 (PDT)

If Name Mangler is to support this feature it would undoubtedly be via the 
ability to look inside text files. Adding/editing metadata is quite 
understandably not within the purview of a file renaming utility.
What I meant was that, in the context of your previous answer *("you'll 
either have to find a way to pull the first lines of text from the file 
into a macOS metadata field, or use a tool that can read files while re*
*naming"), *I wonder if the first of these approaches might be more 
straightforward. Like with the UNIX core commands, do you already have some 
idea of how to do this?

On Tuesday, July 6, 2021 at 5:32:18 PM UTC+2 Many Tricks wrote:

> On Jul 6, 2021, at 6:22 AM, Gsazraetr <[email-masked]> wrote:
>
> > You now have another such request for this feature. I for one am looking 
> to append a certain line from a text file to its filename, not replace it.
>
> Noted.
>
> > Wouldn't it be preferable to first "pull the first lines of text from 
> the file into a macOS metadata field"? That way we could leverage all of 
> Name Mangler's capabilities too. I've drawn a blank when looking for a way 
> to do this and anything without a GUI is Greek to me. 
>
> We can't create macOS metadata for other files, we can only read existing 
> metadata. To support this feature, we'd need to open each readable file and 
> save some amount of text, and we'd have to do it for all such files in the 
> selection. We'd also have to provide some method of previewing that line of 
> text, and then let you select some portion of it, determine where to put it 
> in the filename, etc.
>
> I'm not saying we can't do it, but I am saying it's complicated and is not 
> something that's likely to come in a minor update. But your feedback is 
> appreciated, and the vote count is now two :).
>
> -rob.

---

From: Rob Griffiths <[email-masked]>
Date: Tue, 6 Jul 2021 08:32:15 -0700

On Jul 6, 2021, at 6:22 AM, Gsazraetr <[email-masked]> wrote:

> You now have another such request for this feature. I for one am looking to append a certain line from a text file to its filename, not replace it.

Noted.

> Wouldn't it be preferable to first "pull the first lines of text from the file into a macOS metadata field"? That way we could leverage all of Name Mangler's capabilities too. I've drawn a blank when looking for a way to do this and anything without a GUI is Greek to me. 

We can't create macOS metadata for other files, we can only read existing metadata. To support this feature, we'd need to open each readable file and save some amount of text, and we'd have to do it for all such files in the selection. We'd also have to provide some method of previewing that line of text, and then let you select some portion of it, determine where to put it in the filename, etc.

I'm not saying we can't do it, but I am saying it's complicated and is not something that's likely to come in a minor update. But your feedback is appreciated, and the vote count is now two :).

-rob.

---

From: Gsazraetr <[email-masked]>
Date: Tue, 6 Jul 2021 06:22:48 -0700 (PDT)

You now have another such request for this feature. I for one am looking to 
append a certain line from a text file to its filename, not replace it.
Wouldn't it be preferable to first "pull the first lines of text from the 
file into a macOS metadata field"? That way we could leverage all of Name 
Mangler's capabilities too. I've drawn a blank when looking for a way to do 
this and anything without a GUI is Greek to me. 
On Sunday, January 10, 2021 at 6:33:09 PM UTC+1 Many Tricks wrote:

> On Jan 8, 2021, at 2:34 PM, David Browning <[email-masked]> wrote:
>
> I'm trying to rename a number of .txt files using the first line of text 
> in the file. Thanks for any assistance. this is a fantastic app!
>
>
> Name Mangler doesn't have any ability to see inside files, all it can see 
> is the filename, and any associated macOS metadata. You'll either have to 
> find a way to pull the first lines of text from the file into a macOS 
> metadata field, or use a tool that can read files while renaming. 
>
> One option is the Unix core of macOS, via Terminal. From this thread on 
> stackoverflow...
>
>
> https://stackoverflow.com/questions/36025364/rename-one-file-with-the-first-line-of-the-files-contents-not-batch
>
> ...this should work:
>
> mv foo.txt $(head -n 1 foo.txt).txt
>
> That's for one file, where "foo.txt" is the name of the file to be 
> renamed. You'd have to add a loop to handle multiple files, something like 
> this:
>
>
> https://www.unix.com/shell-programming-and-scripting/188561-rename-mass-files-text-first-line.html
>
> Note that there may be GUI apps that do this, too, but I haven't ever gone 
> looking for any.
>
> Should Name Mangler be able to do this? That's another question :), and 
> one that I can't answer at the moment. So far, in the time I've been with 
> Many Tricks, this is the first such request for this feature that we've 
> had. For now, I'm going to add it to our list of possible future features, 
> and see if there's other requests for the same in the future.
>
> regards;
> -rob.
>
>

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 10 Jan 2021 09:33:06 -0800

On Jan 8, 2021, at 2:34 PM, David Browning <[email-masked]> wrote:

> I'm trying to rename a number of .txt files using the first line of text in the file. Thanks for any assistance. this is a fantastic app!

Name Mangler doesn't have any ability to see inside files, all it can see is the filename, and any associated macOS metadata. You'll either have to find a way to pull the first lines of text from the file into a macOS metadata field, or use a tool that can read files while renaming. 

One option is the Unix core of macOS, via Terminal. From this thread on stackoverflow...

https://stackoverflow.com/questions/36025364/rename-one-file-with-the-first-line-of-the-files-contents-not-batch <https://stackoverflow.com/questions/36025364/rename-one-file-with-the-first-line-of-the-files-contents-not-batch>

...this should work:

That's for one file, where "foo.txt" is the name of the file to be renamed. You'd have to add a loop to handle multiple files, something like this:

https://www.unix.com/shell-programming-and-scripting/188561-rename-mass-files-text-first-line.html <https://www.unix.com/shell-programming-and-scripting/188561-rename-mass-files-text-first-line.html>

Note that there may be GUI apps that do this, too, but I haven't ever gone looking for any.

Should Name Mangler be able to do this? That's another question :), and one that I can't answer at the moment. So far, in the time I've been with Many Tricks, this is the first such request for this feature that we've had. For now, I'm going to add it to our list of possible future features, and see if there's other requests for the same in the future.

regards;
-rob.

---

From: David Browning <[email-masked]>
Date: Fri, 8 Jan 2021 14:34:46 -0800 (PST)

I'm trying to rename a number of .txt files using the first line of text in 
the file. Thanks for any assistance. this is a fantastic app!