views:

389

answers:

8

I often need to copy, move or rename files and directories based on some criteria as I collect data from many resources and I like to keep things organized. What scripting language provides the most intuitive and easy to use methods for these operations? Here is an example scenario:

I keep my music in a folder hierarchy like below:

&Artist Name(upper case letters)&
-- (&album release year&) &album name&
---- \*.*

I want to find out which folders break these rules under my music folder. I would also like to make them fit to the structure I use, if they have a consistent but different structure of file naming and directory schemes.

I work in both Windows and Linux, so I thought of giving bash a try (thanks to cygwin) as I am familiar with it a little. What do you guys think? Is there a better solution?

+5  A: 

If you have cygwin use either bash script or install Python, Perl, or Ruby and use them instead. There is no real "best" when it comes to basic file operations. Just pick which language you like most.

The Wicked Flea
+5  A: 

Perl gets my vote, particularly if you're doing any text searches (or search and replaces). Most modern languages can do this but Perl, to me, has the right combination of brevity and power.

Seeing the revised question however I will say this: you don't need s scripting language. You need a music organizer, like Tag&Rename. It has lots of functionality for tagging music (from Amazon or just from the directory and file names) and re-organising it to any criteria you wish.

cletus
+2  A: 

Tcl is a very good choice (available as ActiveTcl from ActiveState, and works on all platforms), particularly if you think you might want to add a minimal GUI some day. If you hunt for "tclkit", it is a single-file implementation of Tcl which makes installing a matter of copying that one file wherever you want.

Tcl is no better nor worse than Perl, Ruby, Python, or any other scripting language in this regard -- they all do basic file operations with equal aplomb.

Bryan Oakley
+1  A: 

Perl is what I'd use due to its powerful text/string processing capabilities. Besides, you could've just use ActivePerl without cygwin (which is a little bit over kill IMO).

PolyThinker
+1  A: 

Pretty much all of them will do what you're asking. I hate, detest, and thoroughly dislike perl, so I'd suggest python or ruby. The exact thing you want to do can be written very tightly and neatly in python using os.path.walk or os.walk, but python, ruby, bash shell scripting, and even a pipeline of ls -R | aek with an awk program would do it perfectly well.

Charlie Martin
+1  A: 

I'd suggest foobar2000 if you want to organize your music. As well as being an awesome player, it's File Operations component can copy or move files based on custom patterns.

yuriks
A: 

Don't forget Zsh as an option - your bash knowledge is relevant, plus it has got some neat scripting and command-line features.

orip
A: 

As much as it stings, Perl was designed for doing things like this.

Max