Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Move a file to another directory based on regex match

by Marshall (Canon)
on Feb 25, 2021 at 21:35 UTC ( #11128802=note: print w/replies, xml ) Need Help??


in reply to Move a file to another directory based on regex match

Start simple:
I may be wrong, but I think your regex is wrong.
'+' is not a valid file name character.
Start by printing the proposed files to be moved:
I don't know what \+ means?
#!/usr/bin/perl use strict; use warnings; use File::Copy; my ($inDir, $outDir) = @ARGV; opendir (DIR, $inDir) or die "Bad Input Directory $inDir $!\n"; while (my $infile = readdir(DIR)) { if ($infile =~ 'F\d{8}\.\d{4}\+\d{4}\-\d{4}\+\d{4}_.*') #like F12345678.1234+1234-9876+3456..... { print "$inDir/$infile\n"; } }

Replies are listed 'Best First'.
Re^2: Move a file to another directory based on regex match
by parv (Vicar) on Feb 26, 2021 at 01:53 UTC
Re^2: Move a file to another directory based on regex match
by Anonymous Monk on Feb 25, 2021 at 22:23 UTC
    '+' is not a valid file name character.

    yes it is. read the thread. this isnt windows.

      No issue on Windows 10 either in Windows Powershell with vim x+v.

Re^2: Move a file to another directory based on regex match
by DAN0207 (Acolyte) on Feb 26, 2021 at 17:02 UTC

    Thanks a ton!! It worked. I was missing on many other things which i cleared from your suggestions.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11128802]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2021-05-10 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (103 votes). Check out past polls.

    Notices?