INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: OT: Renaming files based on case  (Read 1943 times)

jkrzok

  • Regular Member
  • World Citizen
  • ***
  • Posts: 184
  • Change this by choosing profile
OT: Renaming files based on case
« on: January 26, 2007, 11:42:38 pm »

IHaveSeveralHundredFilesNamedSomethingLikeThis

I would like to Have Several Hundred Files Named Something Like This.

Does anyone know of anyway to batch seperate words in a file name based on the case of the letters? The renaming software I'm familiar with can't do it. If it can be done in MC I'd be thrilled but I'm willing to look to other software (hopefully free) to do the job.
Logged

dcwebman

  • Citizen of the Universe
  • *****
  • Posts: 2154
Re: OT: Renaming files based on case
« Reply #1 on: January 27, 2007, 05:29:34 pm »

I am not much of an expert with regular expressions but Bulk Rename Utility (http://www.bulkrenameutility.co.uk/) supports them and I would guess that with regular expressions you could do what you want.
Logged
Jeff

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20063
Re: OT: Renaming files based on case
« Reply #2 on: January 27, 2007, 05:38:30 pm »

Quote
Does anyone know of anyway to batch separate words in a file name based on the case of the letters?

I Actually Made A Plug-In Once To Do This, It Was Part Of Another Program I Called The Option De-Scrunching.
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio, Music
https://MyAAGrapevines.com
https://centercitybbs.com
Fayetteville, NC, USA

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Logged
The opinions I express represent my own folly.

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20063
Re: OT: Renaming files based on case
« Reply #4 on: January 27, 2007, 05:45:20 pm »

Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio, Music
https://MyAAGrapevines.com
https://centercitybbs.com
Fayetteville, NC, USA

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: OT: Renaming files based on case
« Reply #5 on: January 27, 2007, 07:32:11 pm »

You're correct - I misread the request.  To atone for my sins,

1) download and install the free ActivePerl :  http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.8.819-MSWin32-x64-267479.msi

2) Copy and paste the following script to a text file:

------- cut -----------
if ($#ARGV <= 0) {
   $mydir =  ".";
} else {
   $mydir = $ARGV[0];
}

print "Rename files in directory $mydir (y/n) ?\n";
$answer = <STDIN>;
chomp $answer;
exit if ($answer =~ /^[nN]/);

print "Renaming files from directory: $mydir\n";
opendir(THISDIR, $mydir) or die "Can't open directory $mydir: $!";
@allfiles = grep { $_ ne '.' and $_ ne '..' and $_ ne "rename.pl"} readdir THISDIR;
closedir THISDIR;

foreach (@allfiles) {
    my $save = $_;
    if (-e $save) {
        s/([A-Z])([a-z]*)/$1$2 /g;
        s/ (\..*)?$/$1/;
        print "Renaming \"$save\" to \"$_\"\n";
        rename "$save", "$_";
    }
}
print "Enter to exit\n";
$answer = <STDIN>;
------- cut -----------

3) Rename the text file to "rename.pl" and place this into your folder with the files you want to rename.
4) Double click the file to rename all the files in the directory as per your request.

Do this on a copy of a couple of files first to be sure its what you want.  There is no undo!
Logged
The opinions I express represent my own folly.

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20063
Re: OT: Renaming files based on case
« Reply #6 on: January 27, 2007, 08:48:08 pm »

Your Sins Are Forgiven My Son
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio, Music
https://MyAAGrapevines.com
https://centercitybbs.com
Fayetteville, NC, USA

jkrzok

  • Regular Member
  • World Citizen
  • ***
  • Posts: 184
  • Change this by choosing profile
Re: OT: Renaming files based on case
« Reply #7 on: January 28, 2007, 09:51:47 pm »

My space bar thanks you.

My near-sighted eyes thank you.

And I thank you all; much drudgery avoided.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: OT: Renaming files based on case
« Reply #8 on: January 28, 2007, 11:34:41 pm »

Glad it worked out ( I presume!).
Logged
The opinions I express represent my own folly.

ThoBar

  • Citizen of the Universe
  • *****
  • Posts: 992
  • Was confishy
Re: OT: Renaming files based on case
« Reply #9 on: January 29, 2007, 12:59:59 am »

Any vbscript / jscript bunnies out there want to write a version that can be run via the native windows script host?

i would if i could, but i cant so i wont. may still try though  :-\
Logged

KingSparta

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 20063
Re: OT: Renaming files based on case
« Reply #10 on: January 29, 2007, 05:27:29 am »

I will Add It To My New Project.
Logged
Retired Military, Airborne, Air Assault, And Flight Wings.
Model Trains, Internet, Ham Radio, Music
https://MyAAGrapevines.com
https://centercitybbs.com
Fayetteville, NC, USA
Pages: [1]   Go Up