Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:
This is a simple script which sorts TV show episodes into the right folders, it comes down to this basic example:
### I run this from the command line: /usr/bin/perl mover.pl The.Rookie.S05E14.720p.HEVC.x265-MeGusta[eztv.r +e].mkv
The script dies here:
unless ( -e $ARGV[0] ) { die("$ARGV[0] doesn't exist"); }
But:
If I skip the file-exists test and go right to moving the file to the correct folder, I can do this:
say "move command: 'mv $ARGV[0] ./r/'"; system("mv $ARGV[0] ./r/");
The mv command in the system() call fails with "No such file or directory", but the exact same command, if I copy and paste it from the perl script's output and hit enter, works just fine.
Is it the brackets in the filename? I tried escaping them and it make no difference. The only wrinkle I can think of is that this is happening on MacOS, but the files in question are on a share from a Linux NAS, could that be causing issues?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why does system("mv $x $y") not work when it works at the command line? (updated)
by haukex (Archbishop) on Feb 03, 2023 at 04:58 UTC | |
|
Re: Why does system("mv $x $y") not work when it works at the command line?
by sectokia (Friar) on Feb 03, 2023 at 04:51 UTC | |
|
Re: Why does system("mv $x $y") not work when it works at the command line?
by hv (Prior) on Feb 03, 2023 at 03:04 UTC | |
by Fletch (Bishop) on Feb 03, 2023 at 14:47 UTC | |
|
Re: Why does system("mv $x $y") not work when it works at the command line?
by misterperl (Friar) on Feb 03, 2023 at 17:32 UTC | |
|
Re: Why does system("mv $x $y") not work when it works at the command line?
by harangzsolt33 (Deacon) on Feb 03, 2023 at 02:49 UTC | |
|
Re: Why does system("mv $x $y") not work when it works at the command line?
by Anonymous Monk on Feb 03, 2023 at 11:44 UTC |