Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Faster, More Compact' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Faster, More Compact
Authored by: nicksay on Sep 24, '05 01:13:11AM
Here's another version of the shell script. It executes completely within the bash shell, so it's faster than scripts that call other utilities. For those who like such things, it's highly compact as well. Finally it works on the command line as well as in Automator.

#/bin/bash
for i in "$@"; do if [ -d "$i" ]; then
  i="${i%/}"; f="${i##*/}"; p="${i%/*}"
  [[ "$f" = "$p" ]] && p="."
  [[ $f == *.fpbf ]] && n="${f%.fpbf}" || n="$f.fpbf"
  mv -v "$i" "$p/$n"
fi; done
Note that your shell should be "/bin/bash" in Automator.

[ Reply to This | # ]
Faster, More Compact
Authored by: bluehz on Sep 24, '05 04:01:24AM

The bash script works great as Automator action. Thx!



[ Reply to This | # ]
Faster, More Compact
Authored by: dashard on Sep 24, '05 10:07:01PM
The compact bash script posted above works phenomenally well, and wicked fast too. I saved mine as a Finder plug-in for Automator, so all I have to do is right-click the deired folder to toglle the setting. I names the script/plug-in "Burn Folder Toggle".

One note of advice: if you intend to use this script in this way, make sure that you set up Automator to "pass input as arguments" or the whole thing will fail (gracefully).

Bravo and well done!

[ Reply to This | # ]
Me Talk Pretty One Day
Authored by: dashard on Sep 24, '05 10:09:30PM

An d me t hin k that me shoud reed ovr my writng be4ore posting nex tim e.

(My apologies for the previous typo-fest!) :-)



[ Reply to This | # ]
Faster, More Compact v2
Authored by: nicksay on Nov 06, '05 09:39:52PM
If you have the Developer Tools installed, then you can run an improved version of this script. You can use the SetFile tool to hide the burn folder extension in the Finder. Use the following code in place of the above:
#!/bin/bash
for i in "$@"; do if [ -d "$i" ]; then
	i="${i%/}"; f="${i##*/}"; p="${i%/*}"; e="e"
	[[ "$f" = "$p" ]] && p="."
	[[ $f == *.fpbf ]] && n="${f%.fpbf}" || { n="$f.fpbf"; e="E"; }
	sf="/Developer/Tools/SetFile"
	[ -x "$sf" ] && $sf -a $e "$i"
	mv -v "$i" "$p/$n"
fi; done
If you're making this an automator action, make sure your shell is /bin/bash and be sure pass the input as arguments.

[ Reply to This | # ]