diff options
author | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2012-02-18 18:34:06 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2012-02-18 18:34:06 +0100 |
commit | 30ba1c538acd157e2be7bd3cc0361250ed34959d (patch) | |
tree | 9aec30abdd9557b68c4539e494cf67830c9d63be | |
parent | e339face270549fa90f64c86b9ac2097d8c1462b (diff) |
check if file exists
-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" |