Computing.Net > Forums > Windows 2000 > Batch file to rename and delete dir

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file to rename and delete dir

Reply to Message Icon

Name: averacruz
Date: December 10, 2004 at 13:05:27 Pacific
OS: Windows 2000
CPU/Ram: P3, 256MB
Comment:

Hi there. I may have posted this in the wrong topic area before, so I thought I would try moving it here.

I have just recently found myself in the realm of writing batch files, so bear with my in my ignorance.

I am currently attempting to write a batch file that will be placed within a specific directory, and then be executed, renaming all of the files within that directory.

I am using Photoshop Elements' batch processing to resize and rename all of my photos, and save them to the directory I specify. However, unlike Photoshop, Elements limits the user to only using two values when selecting a naming scheme. Thus, rather than run a second batch in Elements, I just want to set up a dos batch file that will add the third element to my filenames.

When Elements exports the new, resized files, it names them firstname_lastname#.jpg (i.e. John_Smith1.jpg). Now, for my website, I need both thumbnail versions and full size versions of the photos. Each photo is should be denoted by a "_lg" or "_sm" at the end of it, depending on it's size. Thus, the final filename should read John_Smith1_lg.jpg.

NOTE: I don't know if this matters or not, but some files I name with just firstname, so they would be John1_lg in the end.

Now, let me explain the process I am using to make this as efficient as possible, and perhaps we can add things to the batch file to speed things up even more.

1) I create a directory for someone's photos ( C:\John Smith ).
2) I place all of the original, unedited photos in this directory.
3) I run a batch file in Photoshop Elements that resizes, reduces resolution, and renames each file, and have it save it in a subdirectory named Edited. ( C:\John Smith\Edited )
4) Here is where I need the first dos batch file. It will rename the files to John_Smith1_lg.jpg.
5) If possible, I would like the batch file to also cut and paste the newly renamed files into the main John Smith directory.
6) Now I run the second batch in Elements, creating the thumbnail version of the photos, and again saving it into the "Edited" directory.
7) Here is where the second dos batch file is needed. It will rename the files to John_Smith1_sm.jpg. I would also like this second batch to cut and copy the files it has renamed and paste them into the main John Smith directory, and then delete the "Edited" directory completely, as it is no longer needed.

One final note, the directory structure I am using for this project is not as simple as C:\foldername. It's actually L:\Folder1\Folder2\Folder3\Folder4\Folder5, where folders 3, 4 and 5 are different each time. Folder 5 is the directory I create to store the files, listed in Step 1 above. (I.e. John Smith).

Here is the part I wrote already:
===============
@echo off
RENAME *.jpg *_lg.jpg
===============

But that didn't work, and doesnt do half the stuff I mentioned above... help this n00b out, please? :) I can provide you with any additional information you need, I just didn't know what was pertinant. Oh one thing I forgot, due to the LONG file structure I am using for this, I think my easiest course of action would be to simply copy and paste these bat files into each "Edited" directory, whenever I need it. That way I don't have to remember the entire directory address each time.



Sponsored Link
Ads by Google

Response Number 1
Name: Steve Dunn
Date: December 10, 2004 at 18:20:00 Pacific
Reply:

Your post is long and confusing. Usining rename command you need ti use ? rather than * - but you need to know the length of each 'name' so you can provide the right number of ? (eg, your example RENAME *.jpg *_lg.jpg for John_Smith would need to be RENAME ??????????1.jpg ???????????1_lg.jpg - but that's just one file - part of the confusion).

Would something like http://www.musicsucks.com/CKSoft/CKRename/ be any use?


0
Reply to Message Icon

Related Posts

See More


annoying toolbar System 32 Errors



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Batch file to rename and delete dir

Batch file to delete the temp files www.computing.net/answers/windows-2000/batch-file-to-delete-the-temp-files/33636.html

Batch file to configurate Group Policy www.computing.net/answers/windows-2000/batch-file-to-configurate-group-policy/24563.html

Sending batch files to background? www.computing.net/answers/windows-2000/sending-batch-files-to-background/36275.html