Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 21 guests and 1 member online
 
Free Business and Tech Magazines and eBooks

You are here: Home arrow Ethical Hacking Discussions and Related Certificationsarrow Programmingarrow batch file help
EH-Net
May 19, 2013, 01:10:43 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: batch file help  (Read 5167 times)
0 Members and 1 Guest are viewing this topic.
O_o
Newbie
*
Offline Offline

Posts: 28


View Profile
« on: December 28, 2011, 09:48:05 AM »

I need to make a batch file that will automaticly renamed files to numbers.
 Huh
Logged

If your computer speaks English, than it was probably made in Japan.
Ignatius
Jr. Member
**
Offline Offline

Posts: 91


View Profile
« Reply #1 on: December 28, 2011, 12:41:43 PM »

I'm not saying that I will necessarily be able to help, but can you give examples of how you need to have them renamed, i.e. maybe:

one.txt -----> 1.txt
two.txt ------> 2.txt
three.txt ----> 3.txt
four.txt -----> 4.txt

or

jpvf.doc ------------> 1
wioeprt.rtf ----------> 2
wdopemxs.jpg -----> 3
qwerty.wmv --------> 4

etc.
Logged
hayabusa
Hero Member
*****
Offline Offline

Posts: 1630



View Profile
« Reply #2 on: December 28, 2011, 01:44:36 PM »

You could write something like the following:

rename.bat

set /a j=0

setlocal ENABLEDELAYEDEXPANSION

for /f %%a IN ('dir /b *.*') do (

set /a j=j+1

rename %%a !j!%%~xa

)


Edit:  The %%~xa preserves the file extension. Note, if you don't MOVE the resulting file to somewhere else, such as don't use rename but instead

copy %%a <some directory>/!j!%%~xa

it'll try to catch the renamed files, too...  So I'd use the copy and a temp dir, instead, perhaps creating the temp dir at the beginning of the batch file...
« Last Edit: December 28, 2011, 01:48:54 PM by hayabusa » Logged

~ hayabusa ~ 

"All men can see these tactics whereby I conquer, but what none can see is the strategy out of which victory is evolved." - Sun Tzu, 'The Art of War'


OSCE, OSCP , GPEN, C|EH
O_o
Newbie
*
Offline Offline

Posts: 28


View Profile
« Reply #3 on: April 19, 2012, 04:29:55 PM »

Thanx Mr.Hayabusa
Logged

If your computer speaks English, than it was probably made in Japan.
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.06 seconds with 22 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Free Business and Tech Magazines and eBooks

© 2013 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.