# DRAG & DROP FILES do { print "\n\n-------------------------------------------------"; print "\n\nDrag and drop file 1 here and press enter.\n"; chomp ($file1_full = ); # windows doesn't add quotes if there is no space in the path, linux adds single quotes # strip any leading and trailing spaces and quotes; $1=everything up to last / or \, $2= everything from there up to the end except spaces and "'. $file1_full =~ /^ *[\"\']?(.*)[\/\\]([^\"\']*)[\"\']? *$/; $folder = $1; $file1 = $2; $file1 =~ /(.*)\.(.*)/; $f1 = $1; $ext = lc($2); print "\nDrag and drop file 2 here and press enter. (This file has to be in the same folder as file 1!)\n"; chomp ($file2_full = ); $file2_full =~ /^ *[\"\']?(.*)[\/\\]([^\"\']*)[\"\']? *$/; $folder2 = $1; $file2 = $2; $file2 =~ /(.*)\.(.*)/; $f2 = $1; $ext2 = lc($2); print LOG "\nInput files dropped in: $file1 (${file1_full}), $file2 (${file2_full})"; unless ("$folder" eq "$folder2") { print "\n\n\nERROR! The two files are not in same folder. Try again!\n($folder vs ${folder2})\n"; print LOG "\nERROR: The two files are not in same folder. $folder, $folder2"; } unless ("$file1_full" ne "$file2_full") { print "\n\n\nERROR! You dragged in the same file twice. Try again!\n"; print LOG "\nERROR: Same file dropped in twice"; } unless ("$ext" eq "$ext2") { print "\n\n\nERROR! The file extensions don't match. Try again!\n($ext vs. $ext2)\n"; print LOG "\nERROR: Extensions don't match: $ext vs. $ext2"; } unless (-e "$folder/$file1") { print "\n\n\nERROR! File 1 not found (maybe its path or its filename contains accented letters). Try again!\n(file: $folder/$file1)\n"; print LOG "\nERROR: File 1 not found; folder: $folder, file: $file1"; } unless (-e "$folder2/$file2") { print "\n\n\nERROR! File 2 not found (maybe its path or its filename contains accented letters). Try again!\n(file: $folder2/$file2)\n"; print LOG "\nERROR: File 2 not found; folder: $folder2, file: $file2"; } if ($ext eq "doc") { print "\n\n\nERROR! Doc files are not supported. Convert to docx or txt and try again!\n"; print LOG "\nERROR: doc file dropped in"; } $alignfilename = "${f1}-${f2}"; close LOG; open (LOG, ">>:encoding(UTF-8)", "$scriptpath/scripts/log.txt") or print "\nCan't create log file: $!\nContinuing anyway.\n"; } until (("$folder" eq "$folder2") && ("$file1_full" ne "$file2_full") && ("$ext" eq "$ext2") && (-e "$folder/$file1") && (-e "$folder/$file2") && ($ext ne "doc"));