A string manipulation question

J

John Yoo

Hi, I am new to PERL and have a string manipulation question.

I found a DOS command program called xxmklink that creates shortcuts
for a given file. The syntax is: xxmklink "path of the shortcut name"
"path of the object file name"

I would like to find all the .bat files in its directory and all
subdirectories. Then capture all the characters from the last "\" to
".bat" for the shortcut name. For example, the command finds
"C:\some_dir\another_dir\a_filename.bat, then the shortcut name is
a_filename. What command(s) should I use? How is this written? Is
this possible?

[note: I am using AcitvePerl for Windows.]

Any advice will be greatly appreciated.

Thanks!
John
 
J

Jürgen Exner

John said:
Hi, I am new to PERL and have a string manipulation question.

The programing language is called Perl, the interpreter is called perl.
There is no PERL.
For further details see "perldoc -q difference":
What's the difference between "perl" and "Perl"?
I would like to find all the .bat files in its directory and all
subdirectories. Then capture all the characters from the last "\" to

The File::Find module is your friend, see "perldoc File::Find"
".bat" for the shortcut name. For example, the command finds
"C:\some_dir\another_dir\a_filename.bat, then the shortcut name is
a_filename. What command(s) should I use? How is this written? Is
this possible?

The File::Basenaem module is your friend, see "perldoc File::Basename"

jue
 
D

Dr.Ruud

John Yoo schreef:
I found a DOS command program called xxmklink that creates shortcuts
for a given file. The syntax is: xxmklink "path of the shortcut name"
"path of the object file name"

On NTFS there are also hardlinks and softlinks, see Win32::Hardlink and
Win32::Symlink.
http://search.cpan.org/~autrijus/Win32-Hardlink-0.02/Hardlink.pm

I would like to find all the .bat files in its directory and all
subdirectories. Then capture all the characters from the last "\" to
".bat" for the shortcut name. For example, the command finds
"C:\some_dir\another_dir\a_filename.bat, then the shortcut name is
a_filename. What command(s) should I use? How is this written? Is
this possible?


For less surprises, always use the forward slash '/'.

Check out http://search.cpan.org/~ingy/IO-All-0.33/lib/IO/All.pod for
all traversing and manipulating your filesystem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top