#!/usr/bin/perl use strict; use warnings; $| = 1; use File::Find; use DBI; # Verzeichnis von Kommandozeile holen my $verzeichnis = shift(@ARGV) || 'C:\Users\Ordner'; my $ausgabe_verzeichnis = shift(@ARGV) || 'C:\CSV_Ordner'; my $cvs_name = "dir.csv" my $id = 0; my $parent; my %ids; my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_dir => $ausgabe_verzeichnis, csv_tables => { dir => { file => $cvs_name } }, }); $dbh->do ("DROP TABLE dir"); $dbh->do ("CREATE TABLE dir (fullname CHAR (64), name CHAR (64),size INTEGER,id INTEGER,pid INTEGER,mtime INTEGER)"); my $sth=$dbh->prepare('INSERT INTO dir (fullname,name,size,id,pid,mtime) VALUES(?,?,?,?,?,?)'); sub wanted { return if ( $_ eq '..' ); return if ( $_ eq '.' ); $ids{ $File::Find::name } = $id; $parent = $File::Find::dir; $sth->execute( $File::Find::name, $_, (stat($File::Find::name))[7], $ids{ $parent }, (stat($File::Find::name))[9], ); } } $sth->finish(); $dbh->disconnect();