How to bulk change .JPG to .jpg in a directory? (Solved)
- Eastern Counties
- Posts: 145
- Joined: Tue 31 Jan 2006, 18:09
- Location: UK
How to bulk change .JPG to .jpg in a directory? (Solved)
When I download photos from my camera they are given a .JPG extension. Photobucket only seems to recognise .jpg. Is there any way I can bulk change the extension in Rox or Gimp?
Thanks
John
Thanks
John
(EDIT: see next posts before you jump into this)
how is your php?
from the php manual, more details at
http://th2.php.net/manual/en/function.rename.php
havent tested it but would assume it would work.
basic code
to iterate through a directory:
how is your php?
from the php manual, more details at
http://th2.php.net/manual/en/function.rename.php
havent tested it but would assume it would work.
basic code
Code: Select all
<?php
rename("/tmp/tmp_file.txt", "/home/user/login/docs/my_file.txt");
?>
Code: Select all
<?php
//changes files in $directory with extension $ext1 to have extension $ext2
//note that if file.ext2 already exists it will simply be over-written
function changeext($directory, $ext1, $ext2, $verbose = false, $testing=true) {
if ($verbose && $testing) { echo "Testing only . . . <br />";}
$num = 0;
if($curdir = opendir($directory)) {
if ($verbose) echo "Opening $directory . . .<br />";
while($file = readdir($curdir)) {
if($file != '.' && $file != '..') {
$srcfile = $directory . '/' . $file;
$string = "$file";
$str = strlen($ext1);
$str++;
$newfile = substr($string, 0, -$str);
$newfile = $newfile.'.'.$ext2;
$dstfile = $directory . '/' . $newfile;
if (eregi("\.$ext1". '$' ,$file)) { # Look at only files with a pre-defined extension, '$' ensures the ext is only at they end of the filename
//I think the next two lines are unnecessary but they
//don't hurt anything so I'm leaving them
$fileHand = fopen($srcfile, 'r');
fclose($fileHand);
if (!$testing) {
$result=rename($srcfile, $dstfile );
if (!$result) echo "ERROR renaming $srcfile -> $dstfile<br />";
}
if ($verbose) echo "$srcfile -> $dstfile<br />";
}
if(is_dir($srcfile)) {
$num += changeext($srcfile, $ext1, $ext2, $verbose, $testing);
}
}
}
closedir($curdir);
}
return $num;
}
$testing=true;
$verbose=true;
//example usages, first run with $testing set to false, then change $testing to true to do them for real:
//changeext('your/directory', 'php', 'html', $verbose, $testing);
//changeext('your/directory', 'html', 'php', $verbose, $testing);
?>
Last edited by aarf on Wed 27 May 2009, 14:28, edited 1 time in total.
coolpuppyluvr wrote: Hello,
Use the bulk renaming feature of Rox...Highlight all the pics, right click, and select rename, and change the suffix to jpg....
Code: Select all
\.JPG
Code: Select all
.jpg
- Attachments
-
- rename.jpg
- (38.17 KiB) Downloaded 619 times
- Eastern Counties
- Posts: 145
- Joined: Tue 31 Jan 2006, 18:09
- Location: UK
Re: bulk rename in ROX
What's nice to know?sky king wrote:Nice to know, thanks.
I'm afraid not.. Just a Filesystem->PRenameSemme wrote:Isn't there a "MultiRename" in your menu?
I think I tried MultiRename (there is a recent pet in the forum, right?) but did not work on Slacko 6.3.2
I'm afraid I've resorted to wine namely an app called den4b-renamer which seems to work well with Puppy well.. It cannot be restored after being minimized so in this case you're forced to kill it
Semme, is there a way to limit this to just a defined set of directories so it doesn't go through the entire computer, changing everything it finds?
I suppose if it were run from a console that had been opened in the directory that contains only the directories to be changed, that might do it. In Rox, the ` key opens a console in the directory Rox is in.
I suppose if it were run from a console that had been opened in the directory that contains only the directories to be changed, that might do it. In Rox, the ` key opens a console in the directory Rox is in.
I don't understand upon what nor from where though I'd like to know how to script a bit like you to make a simplified gui imitation of den4b-renamer. I like this renamer because it allows you to build out a list of steps to take when renaming files. So, you could make a step-by-step list of rules to make the changes you need. It has full preview mode so you can be certain exactly what's going to change to whatSemme wrote:Speak up if you don't understand how or from where to use this.