Adding a new prefix to multiple files - any easy way?
Discussion
If I had 100+ files I need to rename but keep their naming structure and current names, but just add a new prefix to each one.
e,g change
image41.gmt
cube_map.jpg
body1.dds
by adding 138_ to the front into
138_image41.gmt
138_cube_map.jpg
138_cube_map.jpg
It a batch conversion app I'm after than can rename many different files just by adding a standard prefix and not changing any other part of the naming.
Any recommendations or know of anything to do this?
e,g change
image41.gmt
cube_map.jpg
body1.dds
by adding 138_ to the front into
138_image41.gmt
138_cube_map.jpg
138_cube_map.jpg
It a batch conversion app I'm after than can rename many different files just by adding a standard prefix and not changing any other part of the naming.
Any recommendations or know of anything to do this?
I've used File Renamer hundreds of times for jobs like this - freeware, and a very well designed piece of software.
Download link: www.sherrodcomputers.com/downloads%5CFileRenamerBasic.exe
Download link: www.sherrodcomputers.com/downloads%5CFileRenamerBasic.exe
The perl "rename" program. Don't leave home without it;
($op = shift) || die "Usage: rename perlexpr [filenames] ";
if (!@ARGV) {
@ARGV = <STDIN>;
chop(@ARGV);
}
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}
In your case it would be called as;
rename 's/^/138_/;' *
($op = shift) || die "Usage: rename perlexpr [filenames] ";
if (!@ARGV) {
@ARGV = <STDIN>;
chop(@ARGV);
}
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}
In your case it would be called as;
rename 's/^/138_/;' *
nope sent it as that. It's probably hotmail arseing about!
This is a link to it anyway
http://cerebralsynergy.com/download.p
This is a link to it anyway
http://cerebralsynergy.com/download.p
If you're running a recent version of Windows you can do that using the DOS shell extensions if you don't mind typing the command in. It will be something along the lines of:
for %f in ( <my list of files> ) do rename %f foo_%f
Replace <my list of files> with a wildcard expression that selects the files you want to rename, *.mpg etc.
for %f in ( <my list of files> ) do rename %f foo_%f
Replace <my list of files> with a wildcard expression that selects the files you want to rename, *.mpg etc.
GreenV8S said:
If you're running a recent version of Windows you can do that using the DOS shell extensions if you don't mind typing the command in. It will be something along the lines of:
for %f in ( <my list of files> ) do rename %f foo_%f
Replace <my list of files> with a wildcard expression that selects the files you want to rename, *.mpg etc.
for %f in ( <my list of files> ) do rename %f foo_%f
Replace <my list of files> with a wildcard expression that selects the files you want to rename, *.mpg etc.
I was going to suggest that - only the Unix equivalent... best use of cygwin on Windows.
BliarOut said:
Church of Noise said:
The simple way of doing it: put the files in a separate directory, go into command prompt and type
rename *.* 138_*.*
rename *.* 138_*.*
Although
ren *.* 138_*.*
saves you typing three characters

I was going to suggest that but did I test first and whenever I did it, it added an additional '.' between the prefix and the original name, hence I didn't recommend that option.
eyebeebe said:
BliarOut said:
Church of Noise said:
The simple way of doing it: put the files in a separate directory, go into command prompt and type
rename *.* 138_*.*
rename *.* 138_*.*
Although
ren *.* 138_*.*
saves you typing three characters

I was going to suggest that but did I test first and whenever I did it, it added an additional '.' between the prefix and the original name, hence I didn't recommend that option.
That's odd.... In theory there shouldn't be any difference. Ah well, such is 'Doze

Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff


