BleepingComputer.com: Remove extension with .bat file

Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Remove extension with .bat file Coding - Win98

#1 User is offline   Lynx560 

  • New Member
  • Pip
  • Find Topics
  • Group: Members
  • Posts: 14
  • Joined: 24-December 06

Posted 09 September 2009 - 11:32 PM

I would like to know to make a .bat file that will remove an extension from a file (or many files) that could be located anywhere on my computer.

For example:
C:\MyBackups\090809.tif
C:\TEST\090809.tif
D:\Backups\090809.tif

to
C:\MyBackups\090809
C:\TEST\090809
D:\Backups\090809

(I used .tif as an example, but I want to be able to adapt it so it will delete any extension)

I would also like this .bat to run each time Windows boots - in the background (without a DOS screen)

Is this possible ?

If so, please post exactly what I need to put in my .bat (and exactly where to put it - {root drive?})

Thank you !


EDIT: Moved to a better forum for this subject

This post has been edited by garmanma: 10 September 2009 - 11:54 AM


#2 User is offline   PropagandaPanda 

  • PipPipPipPipPipPip
  • Find Topics
  • Group: Malware Response Instructor
  • Posts: 9,063
  • Joined: 10-March 08
  • Gender:Male

Posted 11 September 2009 - 08:13 PM

Hello Lynx.

This is certainly possible.

You will need to . . .
  • Get a list of files you want to rename.
  • Loop through each of the files with the For Command.
  • Check to see if the name exists (though you've just compiled the list, shouldn't be a problem).
  • Check to see if the name is a folder.
  • Use the advanced For Command feature to retrieve the file name only of the file. This is the main part. You can actually ignore the checking and such.
  • Copy the file to the new filename.
  • Delete the file.
I have created a piece of code to do this, and would be glad to share it. Though, perhaps you would like to try yourself first.

The link below should contain all the information you will need.
http://www.computerhope.com/forhlp.htm

Look at the "optional syntax" section.

Good luck,
The Panda

This post has been edited by PropagandaPanda: 11 September 2009 - 08:16 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users