Appending text to a file name

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Re: Appending text to a file name Wed Apr 18, 2012 2:27 pm • by Mr_Noodle
Search around. You can either find a script written by someone else or maybe someone has done an Automator action for this which would make it even easier. Search for "automator id3 tag".
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Appending text to a file name Mon Apr 23, 2012 11:20 am • by myor
I have searched around and found an iTunes script that converts file name to song name. The script requires the file name to be highlighted before it makes its work automatically. However I do not know of how to continue a rule in Hazel that do these things: highlight and run a script.
myor
 
Posts: 12
Joined: Tue Mar 20, 2012 4:04 pm

Re: Appending text to a file name Mon Apr 23, 2012 12:31 pm • by Mr_Noodle
Highlighted in iTunes? I'd look for a different script.

A quick search turned this up: http://addcast.net/2006/07/08/id3-tagge ... l-fischer/

I don't know if if works as I have no experience with but something worth looking into.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Appending text to a file name Mon Apr 23, 2012 2:17 pm • by myor
Thanks. I checked your tip. Also here you have to highlight the file in Finder that you want to become a tag thru the script. To recap: I have come this far:

If Name matches •title •day.•month.•year •additional text
Then Rename with pattern •title •year•month•day•additional text extension

I wanted to change the file names of an iTunes podcast folder. Now that was solved remains an annoying problem. The changed file names do not change i iTunes itself.

The result is a changed file name of a podcast in a Folder. Next step for Hazel is to pick each of file with a changed file name and "refresh" an ID3 tag so that the name appears correctly in iTunes.

The Apple script I found was
http://dougscripts.com/itunes/scripts/s ... osongnames

My problem:
1) How to get Hazel's grasp the files that were changed and
2) process them in the script

I feel I am near with your support but not there yet.

Thanks.
myor
 
Posts: 12
Joined: Tue Mar 20, 2012 4:04 pm

Re: Appending text to a file name Tue Apr 24, 2012 3:17 pm • by Mr_Noodle
Yes, this is getting a bit outside Hazel support. Any script which relies on the UI (like the current selection) is not a good fit to be used with Hazel. You need to feed Hazel filename. I suggest checking some Automator or Applescript forum for more help. Also, if you are not adept with scripting, I highly recommend taking the Automator route, like the link I posted above.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Appending text to a file name Wed Apr 25, 2012 3:15 am • by myor
Both the script I cited as well as the one you proposed need highlighted name files. You mention coincidentally that Hazel highlights one line at a time. If the highlighting is automatic and maybe it is active when the script takes over.

In order for me to try I would be grateful to know how to invoke the script in this case or if you have a manual that describes it.

Thanks. I feel I am very near.
myor
 
Posts: 12
Joined: Tue Mar 20, 2012 4:04 pm

Re: Appending text to a file name Wed Apr 25, 2012 3:24 pm • by Mr_Noodle
You need to find a script or Automator action that acts on a file input. In Automator, the first action needs to take in a file. Hazel doesn't manipulate the UIs to select the file as that would be bad form (and a bad way of doing it in general). You'll need to find scripts that can take a file input for them to work with Hazel.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Appending text to a file name Fri May 04, 2012 3:02 am • by myor
I am still searching for a script in Automator. When I find it: how do I "embed" it into Hazel?
myor
 
Posts: 12
Joined: Tue Mar 20, 2012 4:04 pm

Re: Appending text to a file name Fri May 04, 2012 11:58 am • by Mr_Noodle
If it's an Automator action, you just need to use the "Run Automator workflow". You can't embed them but can trigger them when they are in an external file.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Appending text to a file name Sun Apr 15, 2018 1:24 pm • by learned
I have a variation of this I am trying to do, but I suck at shell scripts.

If I have files with the following naming pattern:

rootname 2018-01.txt
rootname 2018-02.txt

I would like to append them all to a file named rootname.txt. What I don't know is how to extract just the rootname part of the $1 filename within the shell script.

Thanks
learned
 
Posts: 29
Joined: Sun Jun 21, 2009 5:18 pm

Re: Appending text to a file name Mon Apr 16, 2018 4:01 pm • by Mr_Noodle
If you were using AppleScript, you could have Hazel extract that and pass it into the script. If you need to do it in a shellscript, you can use an AppleScript and have it call the shell script, passing along the relevant part.

Otherwise, you'll need to do your own pattern matching. There are tons of ways of doing it but maybe echo'ing the filename to 'cut', having it split the name on spaces, would do it.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Previous

Return to Support