#!/usr/bin/perl use strict; use warnings; $| = 1; use File::Find; use File::Spec; use Text::CSV; my $verzeichnis = shift(@ARGV) || 'C:\Users\Student\Desktop\Dropbox\Dropbox\AZ Darmstadt'; my $csv_name = shift(@ARGV) || 'C:\Users\Student\Desktop\dir.csv'; my $id = 0; my $parent; my %ids; my $csv=Text::CSV->new( { eol => $/ } ); open(my $cvsfh,'>',$csv_name) or die("ERROR open $csv_name $!\n"); print $cvsfh "#fullname,name,size,id,pid,mtime\n"; find(\&wanted, $verzeichnis); sub wanted { return if ( $_ eq '..' ); return if ( $_ eq '.' ); $ids{ $File::Find::name } = $id; $parent = $File::Find::dir; $csv->print ($cvsfh, [ id => $id++, fullname => $File::Find::name, name => $_, parent => $parent, parentid => $ids{ $parent }, stat => [ (stat($File::Find::name))[8,9,10] ] ; }