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

Cleaning up directory paths, from strings containing multiple instances of directory path+filename

by Amphiaraus (Acolyte)
on Oct 18, 2012 at 20:26 UTC ( #999819=perlquestion: print w/ replies, xml ) Need Help??
Amphiaraus has asked for the wisdom of the Perl Monks concerning the following question:

Is it possible to remove directory paths from directory path + filename strings, leaving the filename only, if more than one directory path + filename string occur as substrings within a larger string?

Example:

Can this string-

with arguments [/C move /Y "E:/Atlas/12_4_0_US/AppImage/Bin/Installed +Providers/VehicleRecords/VehicleRecordUpdateUtility.exe" "E:/Atlas/12 +_4_0_US/EngPublish"]

.. be changed to this string-

with arguments [/C move /Y "VehicleRecordUpdateUtility.exe" "EngPublis +h"]

The above arguments are concerned with moving a file named "VehicleRecordUpdateUtility.exe" to a folder named "EngPublish"

Thank You,

Amphiaraus

Comment on Cleaning up directory paths, from strings containing multiple instances of directory path+filename
Select or Download Code
Re: Cleaning up directory paths, from strings containing multiple instances of directory path+filename
by toolic (Bishop) on Oct 18, 2012 at 20:49 UTC
    use warnings; use strict; use File::Basename; my $str = 'with arguments [/C move /Y "E:/Atlas/12_4_0_US/AppImage/Bin +/Installed Providers/VehicleRecords/VehicleRecordUpdateUtility.exe" " +E:/Atlas/12_4_0_US/EngPublish"]'; $str =~ s/"(.*?)"/'"' . basename($1) . '"'/eg; print "$str\n"; __END__ with arguments [/C move /Y "VehicleRecordUpdateUtility.exe" "EngPublis +h"]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2015-07-06 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (72 votes), past polls