diff options
-rwxr-xr-x | videoadd.pl | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/videoadd.pl b/videoadd.pl index 079a4e3..c26f227 100755 --- a/videoadd.pl +++ b/videoadd.pl @@ -522,12 +522,23 @@ if ( defined ($file) and defined ($sort_flag) ) { } } } - move ( $file, catfile ( $dir, $new{filename} ) ) - or warn "Warning: Cannot move file: $!.\n"; - symlink catfile( updir(), 'DIRECTORS', $new{director}, $new{filename} ), - catfile( $symlinks, $new{filename} ) - or warn "Warning: Cannot create symlink: $!.\n"; + if ( -e catfile ( $dir, $new{filename} ) ) { + warn "Warning: Cannot move file: file exists.\n"; + } + else { + move ( $file, catfile ( $dir, $new{filename} ) ) + or warn "Warning: Cannot move file: $!.\n"; + } + + if ( -e catfile( $symlinks, $new{filename} ) ) { + warn "Warning: Cannot create symlink: file exists.\n"; + } + else { + symlink catfile( updir(), 'DIRECTORS', $new{director}, $new{filename} ), + catfile( $symlinks, $new{filename} ) + or warn "Warning: Cannot create symlink: $!.\n"; + } } else { warn "Warning: Cannot move file (no director found).\n" |