fubz Posted December 11, 2005 Report Share Posted December 11, 2005 I have a folder, lets call it BASE in BASE we have about 200 folders of random names. In each of these folders contain a file called XXXXXX1.gif where XXXXXX is a random set of charcters. I want to rename every XXXXXX1.gif to XXXXXX.gifI know windows has a rename command, but how do i go about setting up the parameters... i cant figure it out. Help Please!Thanks Quote Link to post Share on other sites
jcl Posted December 11, 2005 Report Share Posted December 11, 2005 (edited) Ack, braino. Edited December 11, 2005 by jcl Quote Link to post Share on other sites
shanenin Posted December 11, 2005 Report Share Posted December 11, 2005 (edited) I am guessing you mean like a batch script, batch makes me want to pull my hair out, so I wrote one in python. i am not exacty sure if this is what you need, but my script will do this. If you run the script from inside the folder "BASE" it will change any .gif file found in each of the sub folders to the name you specify in the variable "new_name". Warning . If you have more then one gif per folder it delete all but that last gif.you will need to install python to run the script#!/usr/bin/env pythonimport os# enter the new name you want your gifs changed to below new_name = "enter-name-here.gif"for i in os.listdir(os.getcwd()): directory = os.path.abspath(i) if os.path.isdir(directory): for file in os.listdir(directory): if file.endswith(".gif"): old_file = "%s/%s" %(directory, file) new_file = "%s/%s" %(directory, new_name) os.rename(old_file, new_file)I was not sure if you had more then one gif file per folder, if you need something different then this, let me know, then i can change the script.edit added later// I tested it, and it seems to work correctly, if you do decide to use it, I would reccomend making a backup of the directory BASE, just in case it misbehaves Edited December 11, 2005 by shanenin Quote Link to post Share on other sites
Aluvus Posted December 11, 2005 Report Share Posted December 11, 2005 I use Rename Master for these kind of tasks.If you direct it to the folder, open the "Remove" tab, and choose "From name end" with setting 1, it will do what you want.I have an older version, but it should be very similar in the current version. Quote Link to post Share on other sites
rhema7 Posted December 12, 2005 Report Share Posted December 12, 2005 I use 1_4a renamer no install so you can keep on a usb drive for portability.http://www.1-4a.com/rename/Preston Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.