« While I'm name dropping | Main | Doers and watchers »

Which is quicker?

Going to a Finder window with 700-odd images, and dragging them in to chapters by folder?

Or going in to the command line and using a line like this:

$ mv AnPhys-Fig-18-* /Documents/Hill/Hill\ IRCD\ Revision\ 2/Unlabeled\ JPG/ch18/high-res/

…but with each up-arrow having to tick back through the path to update the chapter numbers?

I wish I could pattern-match on the command line. Can I do that? Something like this:

$ mv AnPhys-Fig-(\d\d)-* /Documents/Hill/Hill\ IRCD\ Revision\ 2/Unlabeled\ JPG/ch$1/high-res/

Of course, $1 is a shell-scripting convention for the first argument after the command, so I doubt I could use it in the command itself.

I know I could do this with Perl, but the scripts I’ve done have been too hard-wired to be useful from the command line. The patterns are too involved.

Now Playing: Lullaby from Sometime Anywhere by The Church

TrackBack

Listed below are links to weblogs that reference Which is quicker?:

» http://www.extendedabstract.com/index.php?p=57 from Extended Abstract
Flashes of Panic asks how to do regular expression matching and substituion from the command line. This reminds me how little I really use the power of my favorite shell -- BASH. Sure, I can do a for loop, a while loop, a back tick, globbing, variabl... [Read More]

Comments

I’m pretty sure there is a way to do it with regular expressions from Bash, but I’m no expert. Here’s how I would do it from the Bash command line:

for ((num=1; num <= 20; ++num)); do for file in ls AnPhys-Fig-$num ; do mv $file /path/ch${num}/more_path; done; done

Post a comment