Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In order to match the criteria of a "coverflow" like soft I have to create a specific folder (named "name_of_the_film") for each film.avi and cover.jpg I have in my film directory :

Today:

d:/film/starwars.avi, 
d:/film/starwars2.avi
d:/film/starwars.jpg
d::film/starwars2.jpg

Tomorrow:

d:/film/starwars
d:/film/starwars/starwars.avi
d:/film/starwars/starwars.jpg 
d:/film/starwars2
d:/film/starwars2/starwars2.avi
d:/film/starwars2/starwars2.jpg 

Is it possible to do this automatically?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I'm not aware of any apps which do this, but you can write a short Perl or Python script to do this for you. The following perl script should do what you need:

use File::Copy;

my $baseDir = "D:/film/";

opendir my $dir, $baseDir or die "Cannot open directory: $!";
my @files = readdir $dir;

foreach my $file (@files)
{
  $fileName = $1 if ($file =~ /^(.*)\.[^\.]+$/i);
  mkdir("$baseDir/$fileName") unless (-d "$baseDir/$fileName");
  move("$baseDir/$file", "$baseDir/$fileName/$file");
}

Assuming you have perl installed, save this script as CreateMovieFolders.pl and then run perl CreateMovieFolders.pl from the command-line.

share|improve this answer

You can do it with a batch script.

See here for a list of ways you can mangle for loop variables.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.