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.

Photo

Remove extension with .bat file


  • Please log in to reply
1 reply to this topic

#1 Lynx560

Lynx560

  • Members
  • 41 posts
  • OFFLINE
  •  
  • Local time:02:48 PM

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

Edited by garmanma, 10 September 2009 - 11:54 AM.


BC AdBot (Login to Remove)

 


#2 PropagandaPanda

PropagandaPanda


  • Malware Response Team
  • 10,433 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:48 PM

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

Edited by PropagandaPanda, 11 September 2009 - 08:16 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users