Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by Marshall (Canon)
on Feb 25, 2021 at 21:35 UTC ( [id://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 (Parson) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128802]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-19 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found