program to rename file name

R

randyzapata

I need a program to rename file name.

so the input to run the program would be


RenameFiles //server1/Folder1/folder2/tester.doc
[program name] [location of file]


program would return:

++server1+Folder1+folder2+tester.doc


Can someone please help me?
 
A

A. Sinan Unur

(e-mail address removed) wrote in @o13g2000cwo.googlegroups.com:
I need a program to rename file name.

so the input to run the program would be


RenameFiles //server1/Folder1/folder2/tester.doc
[program name] [location of file]


program would return:

++server1+Folder1+folder2+tester.doc


Can someone please help me?

Have you read the posting guidelines for this group? They are posted here
frequently.

Please show us what you have done so far and exactly where you are having a
problem.

Have you looked at File::Spec?

Specifically, the 'splitdir' method?

Sinan
 
J

Josef Moellers

A. Sinan Unur said:
(e-mail address removed) wrote in @o13g2000cwo.googlegroups.com:

I need a program to rename file name.

so the input to run the program would be


RenameFiles //server1/Folder1/folder2/tester.doc
[program name] [location of file]


program would return:

++server1+Folder1+folder2+tester.doc


Can someone please help me?


Have you read the posting guidelines for this group? They are posted here
frequently.

Please show us what you have done so far and exactly where you are having a
problem.

Have you looked at File::Spec?

Specifically, the 'splitdir' method?

Why using a canon if bow&arrow in the form of a tr/// or y/// would do?
 
A

A. Sinan Unur

A. Sinan Unur said:
(e-mail address removed) wrote in @o13g2000cwo.googlegroups.com:

I need a program to rename file name.

so the input to run the program would be


RenameFiles //server1/Folder1/folder2/tester.doc
[program name] [location of file]


program would return:

++server1+Folder1+folder2+tester.doc
....
Have you looked at File::Spec?

Specifically, the 'splitdir' method?

Why using a canon if bow&arrow in the form of a tr/// or y///
would do?

Because I interpreted the question as dealing with path separators,
rather than plain text.

That is, the task is to split path components, and join them using '+'
for each path component.

Using splitdir makes it obvious to the reader of the code.

Also, split dir does the right thing even when the path above, which
looks like a Windows path, is specified using \ rather than /:

use strict;
use warnings;

use File::Spec::Functions 'splitdir';

my @p1 = join('+', splitdir q{//server1/Folder1/folder2/tester.doc});
my @p2 = join('+', splitdir q{\\\\server1\Folder1\folder2\tester.doc});

print "@p1\n@p2\n";
__END__

Using tr/// and y///, one would have to try to special case this, based
on the OS.

Sinan
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top